An under-examined component of the shrub-annual relationship is how regional drivers, such as climate, may alter the sign or magnitude of positive interactions. Interspecific interactions between plants have been shown to be strongly linked to climate, particularly temperature and precipitation. The stress-gradient hypothesis (SGH) predicts that higher abiotic stress (i.e. for deserts, increasing temperature and reduced precipitation) will increase the frequency of positive interactions among shrubs and their annual understory. Regional climate gradients also have indirect effects on plant composition, such as determining consumer abundance and soil nutrient composition. Nutrient availability is particularly affected by precipitation because of altered decomposition rates of organic matter and mineralization. Therefore, the strength of facilitation and operating mechanism of a shrub on the annual plant community may change along a regional gradient.
We tested the hypothesis that positive interactions among shrubs and annual plants will increase with abiotic stress and reduce nutrient availability along a regional gradient of aridity.
season1.sjd <- season1 %>% filter(Gradient<4) %>% group_by(year, month,days) %>% summarise_if(is.numeric, funs(mean(., na.rm=T)))
season1.mnp <- season1 %>% filter(Gradient>3)%>% group_by(year, month,days) %>% summarise_if(is.numeric, funs(mean(., na.rm=T)))
season2.sjd <- season2 %>% filter(Gradient<4) %>% group_by(year, month,days) %>% summarise_if(is.numeric, funs(mean(., na.rm=T)))
season2.mnp <- season2 %>% filter(Gradient>3)%>% group_by(year, month,days) %>% summarise_if(is.numeric, funs(mean(., na.rm=T)))
## Rain vs Temperature in 2016
par(mfrow=c(2,1))
par(mar=c(3.5,4.5,1,4.5))
plot1 <- barplot(height=season1.sjd$Precip, ylim=c(0,14), ylab="Average precipitation San Joaquin (cm)")
points(plot1[,1], season1.sjd$min.temp, type="l", col="#FF000050", lwd=2)
axis(4, at=seq(0,14,2), lab=seq(0,14,2), ylab="")
mtext("Average temperature at all sites (°C)", 4, line=3)
par(mar=c(4.5,4.5,0,4.5))
plot1 <- barplot(height=season1.mnp$Precip, ylim=c(0,14), ylab="Average precipitation Mojave (cm)")
axis(1, plot1[c(1,30,60,90,120,150,180)], c("Nov","Dec","Jan","Feb","Mar","Apr","May"))
points(plot1[,1], season1.mnp$min.temp, type="l", col="#FF000050", lwd=2)
axis(4, at=seq(0,14,2), lab=seq(0,14,2), ylab="")
mtext("Average temperature at all sites (°C)", 4, line=3)
## Rain vs Temperature in 2017
par(mfrow=c(2,1))
par(mar=c(3.5,4.5,1,4.5))
plot2 <- barplot(height=season2.sjd$Precip, ylim=c(0,14), ylab="Average precipitation San Joaquin (cm)")
points(plot2[,1], season2.sjd$min.temp, type="l", col="#FF000050", lwd=2)
axis(4, at=seq(0,14,2), lab=seq(0,14,2), ylab="")
mtext("Average temperature San Joaquin (°C)", 4, line=3)
par(mar=c(4.5,4.5,0,4.5))
plot2 <- barplot(height=season2.mnp$Precip, ylim=c(0,14), ylab="Average precipitation Mojave (cm)")
points(plot2[,1], season2.mnp$min.temp, type="l", col="#FF000050", lwd=2)
axis(1, plot1[c(1,30,60,90,120,150,180)], c("Nov","Dec","Jan","Feb","Mar","Apr","May"))
axis(4, at=seq(0,14,2), lab=seq(0,14,2), ylab="")
mtext("Average temperature Mojave (°C)", 4, line=3)
### 2016 The rain was inconsistent and mostly absent in the Mojave. This resulted in low germination and producitivty at the southern sites
### 2017 The rain was more plentiful, but in the northern sites, there appears to be a frost period after the majority of the rainfall. Need to check number of frost days
season1.frost <- season1 %>% group_by(Site) %>% summarize(frost.days=sum(min.temp<0, na.rm=T)/length(min.temp)*100)
data.frame(season1.frost)
## Site frost.days
## 1 Barstow 24.725275
## 2 Cuyama 29.670330
## 3 HeartofMojave 25.824176
## 4 PanocheHills 10.439560
## 5 SheepholeValley 6.043956
## 6 Tecopa 23.626374
## 7 TejonRanch 50.549451
season2.frost <- season2 %>% group_by(Site) %>% summarize(frost.days=sum(min.temp<0, na.rm=T)/length(min.temp)*100)
data.frame(season2.frost)
## Site frost.days
## 1 Barstow 17.679558
## 2 Cuyama 19.889503
## 3 HeartofMojave 16.574586
## 4 PanocheHills 14.917127
## 5 SheepholeValley 1.785714
## 6 Tecopa 25.966851
## 7 TejonRanch 35.911602
## Both years had comparable number of frost days
## Compare number of consecutive frost days (i.e. frost periods)
season1[,"frost"] <- ifelse(season1$min.temp<0, -99,season1$min.temp) ## identified days below freezing
season2[,"frost"] <- ifelse(season2$min.temp<0, -99,season2$min.temp) ## identified days below freezing
count.consec <- function(x) {max(rle(as.character(x))$lengths)}
season1.frost <- season1 %>% group_by(Site) %>% summarize(count.consec(frost))
data.frame(season1.frost)
## Site count.consec.frost.
## 1 Barstow 10
## 2 Cuyama 10
## 3 HeartofMojave 12
## 4 PanocheHills 5
## 5 SheepholeValley 7
## 6 Tecopa 11
## 7 TejonRanch 14
season2.frost <- season2 %>% group_by(Site) %>% summarize(count.consec(frost))
data.frame(season2.frost)
## Site count.consec.frost.
## 1 Barstow 5
## 2 Cuyama 6
## 3 HeartofMojave 7
## 4 PanocheHills 6
## 5 SheepholeValley 3
## 6 Tecopa 7
## 7 TejonRanch 13
## compare only after plants have germinated
season1.frost <- season1 %>% group_by(Site) %>% filter(year>2015) %>% summarize(frost.days=sum(min.temp<0, na.rm=T)/length(min.temp)*100, avg.min.temp=mean(min.temp, na.rm=T))
data.frame(season1.frost)
## Site frost.days avg.min.temp
## 1 Barstow 12.396694 5.750413
## 2 Cuyama 11.570248 3.352893
## 3 HeartofMojave 16.528926 4.542149
## 4 PanocheHills 2.479339 6.777686
## 5 SheepholeValley 2.479339 9.394167
## 6 Tecopa 11.570248 6.342149
## 7 TejonRanch 33.884298 1.438017
season2.frost <- season2 %>% group_by(Site) %>% filter(year>2016) %>% summarize(frost.days=sum(min.temp<0, na.rm=T)/length(min.temp)*100,avg.min.temp=mean(min.temp, na.rm=T))
data.frame(season2.frost)
## Site frost.days avg.min.temp
## 1 Barstow 11.666667 6.052500
## 2 Cuyama 16.666667 3.624167
## 3 HeartofMojave 8.333333 5.637838
## 4 PanocheHills 8.333333 6.065833
## 5 SheepholeValley 0.000000 9.386916
## 6 Tecopa 20.833333 5.938333
## 7 TejonRanch 28.333333 2.535833
season1.frost <- season1 %>% group_by(Site) %>% filter(year>2015) %>% summarize(count.consec(frost))
data.frame(season1.frost)
## Site count.consec.frost.
## 1 Barstow 5
## 2 Cuyama 6
## 3 HeartofMojave 4
## 4 PanocheHills 2
## 5 SheepholeValley 2
## 6 Tecopa 4
## 7 TejonRanch 10
season2.frost <- season2 %>% group_by(Site) %>% filter(year>2016)%>% summarize(count.consec(frost))
data.frame(season2.frost)
## Site count.consec.frost.
## 1 Barstow 5
## 2 Cuyama 6
## 3 HeartofMojave 3
## 4 PanocheHills 3
## 5 SheepholeValley 2
## 6 Tecopa 5
## 7 TejonRanch 10
We compared temperature and relative humidity between shrub and open microsites among all sites along the regional gradient
Shapiro-Wilk normality test
data: fit1$residuals
W = 0.87899, p-value < 2.2e-16
Df Sum Sq Mean Sq F value Pr(>F)
Microsite 1 33.6 33.59 76.013 <2e-16 ***
gradient 6 234.0 39.00 88.248 <2e-16 ***
Microsite:gradient 6 8.8 1.46 3.306 0.003 **
Residuals 4290 1896.0 0.44
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
30 observations deleted due to missingness
Analysis of Deviance Table
Model: binomial, link: logit
Response: RH/100
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 4333 974.99
Microsite 1 2.11 4332 972.88 0.1463
gradient 6 528.28 4326 444.60 <2e-16 ***
Microsite:gradient 6 7.44 4320 437.17 0.2824
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Deviance Table
Model: Gamma, link: inverse
Response: swc
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev F Pr(>F)
NULL 404 231.405
Site 6 189.683 398 41.722 381.2179 <2e-16 ***
Microsite 1 0.287 397 41.435 3.4579 0.0637 .
Site:Microsite 6 0.696 391 40.739 1.3994 0.2136
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis of Deviance Table
Model: Gamma, link: inverse
Response: swc
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev F Pr(>F)
NULL 419 183.193
Site 6 144.930 413 38.263 279.4537 <2e-16 ***
Microsite 1 0.080 412 38.183 0.9284 0.3358
Site:Microsite 6 0.535 406 37.647 1.0322 0.4037
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## site coordintes
site.gps <- read.csv("Data/ERGsites.csv")
# nutrient data for each site
nutrients <- read.csv("Data/ERG.soilnutrients.csv")
## long term climate data extracted from worldclim
clim.dat <- read.csv("Data/ERG.worldclim.csv")
## check correlation among long-term climate variables
cor(clim.dat[,3:8]) ## Temp.wettest.QR least correlated
## Annual.Temp Temp.Seasonality Temp.wettest.QR
## Annual.Temp 1.0000000 0.9051791 0.7260617
## Temp.Seasonality 0.9051791 1.0000000 0.4650548
## Temp.wettest.QR 0.7260617 0.4650548 1.0000000
## Annual.precip -0.8911069 -0.9650533 -0.5313460
## Precip.seasonality -0.9715419 -0.9774646 -0.6165170
## Precipt.wettest.QR -0.8839124 -0.9570957 -0.5523347
## Annual.precip Precip.seasonality Precipt.wettest.QR
## Annual.Temp -0.8911069 -0.9715419 -0.8839124
## Temp.Seasonality -0.9650533 -0.9774646 -0.9570957
## Temp.wettest.QR -0.5313460 -0.6165170 -0.5523347
## Annual.precip 1.0000000 0.9613729 0.9980959
## Precip.seasonality 0.9613729 1.0000000 0.9543657
## Precipt.wettest.QR 0.9980959 0.9543657 1.0000000
## Obtain mean shrub traits for each site
shrubs <- read.csv("Data/ERG.shrub.csv")
shrubs <- subset(shrubs, Microsite=="shrub")
shrubs.mean <- shrubs %>% group_by(Gradient,Site) %>% summarise_all(funs(mean))
shrubs.mean <- data.frame(shrubs.mean)
shrubs.vars <- shrubs.mean[,c("Site","Gradient","volume","canopy","Dx","DxEph","Compaction")]
## test correlation among shrub traits
cor(shrubs.vars[,3:7]) ## compaction x volume & DxEph x Dx high correlation
## volume canopy Dx DxEph Compaction
## volume 1.0000000 0.2243902 0.4003665 0.2631563 -0.7023062
## canopy 0.2243902 1.0000000 -0.6847957 -0.3538094 -0.1437590
## Dx 0.4003665 -0.6847957 1.0000000 0.7803527 -0.1355700
## DxEph 0.2631563 -0.3538094 0.7803527 1.0000000 0.3221944
## Compaction -0.7023062 -0.1437590 -0.1355700 0.3221944 1.0000000
vifstep(shrubs.vars[,3:7], th=10) ## Dx showing collinearity problems
## 1 variables from the 5 input variables have collinearity problem:
##
## Dx
##
## After excluding the collinear variables, the linear correlation coefficients ranges between:
## min correlation ( Compaction ~ canopy ): -0.143759
## max correlation ( Compaction ~ volume ): -0.7023062
##
## ---------- VIFs of the remained variables --------
## Variables VIF
## 1 volume 7.026144
## 2 canopy 1.925499
## 3 DxEph 4.316058
## 4 Compaction 6.400914
shrub.site <- shrubs.vars[,-c(1,2,5)]
rownames(shrub.site) <- shrubs.vars[,1]
## PCA of shrub characteristics
pca1 <- prcomp(log(shrub.site), scale=T)
plot(pca1)
biplot(pca1, scale = T)
summary(pca1) ## 77% variation explained
## Importance of components:
## PC1 PC2 PC3 PC4
## Standard deviation 1.3017 1.1778 0.9082 0.3059
## Proportion of Variance 0.4236 0.3468 0.2062 0.0234
## Cumulative Proportion 0.4236 0.7704 0.9766 1.0000
## PCA of site characteristics for season1
## Obtain mean weather variables for each site
season1.mean <- season1 %>% group_by(Gradient,Site) %>% summarise(temp.var=var(avg.temp,na.rm=T),Precip=sum(Precip),wind=mean(wind.speed, na.rm=T))
season1.mean <- data.frame(season1.mean)
## extract key variables
## dropped RH, and chose min.temp because least correlation with others & cold stress
##combine nutrients and long-term averages
site.vars <- data.frame(season1.mean[,3:5],site.gps["elevation"]) ## drop Phosphorus and other climate variables because of correlations,
row.names(site.vars) <- shrubs.vars[,1]
cor(site.vars)
## temp.var Precip wind elevation
## temp.var 1.00000000 -0.8679054 0.05816084 -0.2699588
## Precip -0.86790537 1.0000000 -0.37279135 0.1222504
## wind 0.05816084 -0.3727914 1.00000000 0.1054497
## elevation -0.26995879 0.1222504 0.10544974 1.0000000
site.vars2016 <- site.vars
## check for collinearity
vifstep(site.vars, th=10) ## remove potassium and temperature minimum
## No variable from the 4 input variables has collinearity problem.
##
## The linear correlation coefficients ranges between:
## min correlation ( wind ~ temp.var ): 0.05816084
## max correlation ( Precip ~ temp.var ): -0.8679054
##
## ---------- VIFs of the remained variables --------
## Variables VIF
## 1 temp.var 6.640710
## 2 Precip 7.316232
## 3 wind 1.739558
## 4 elevation 1.142681
pca1 <- prcomp(log(abs(site.vars)), scale=T)
plot(pca1)
biplot(pca1)
## check contribution of loadings
pca1$rotation
## PC1 PC2 PC3 PC4
## temp.var 0.6001002 -0.1669018 0.50554765 -0.5970303
## Precip -0.6703313 -0.1105034 -0.09936844 -0.7270288
## wind 0.2743589 0.7981791 -0.43410209 -0.3149488
## elevation -0.3395039 0.5681927 0.73898773 0.1256633
aload <- abs(pca1$rotation)
sweep(aload, 2, colSums(aload), "/")
## PC1 PC2 PC3 PC4
## temp.var 0.3184748 0.1015355 0.28433406 0.33832382
## Precip 0.3557466 0.0672253 0.05588758 0.41199111
## wind 0.1456030 0.4855763 0.24415109 0.17847449
## elevation 0.1801756 0.3456629 0.41562726 0.07121058
summary(pca1) ## 89% variation explained
## Importance of components:
## PC1 PC2 PC3 PC4
## Standard deviation 1.456 1.0458 0.8577 0.22479
## Proportion of Variance 0.530 0.2734 0.1839 0.01263
## Cumulative Proportion 0.530 0.8034 0.9874 1.00000
gradient1.season1 <- pca1$x[,1]
gradient2.season1 <- pca1$x[,2]
## season2
season2.mean <- season2 %>% group_by(Gradient,Site) %>% summarise(temp.var=var(avg.temp,na.rm=T),Precip=sum(Precip, na.rm=T),wind=mean(wind.speed, na.rm=T))
season2.mean <- data.frame(season2.mean)
## extract key variables
## dropped RH, and chose min.temp because least correlation with others & cold stress
##combine nutrients and long-term averages
site.vars <- data.frame(season2.mean[,3:5],site.gps["elevation"]) ## drop Phosphorus and other climate variables because of correlations,
row.names(site.vars) <- shrubs.vars[,1]
cor(site.vars)
## temp.var Precip wind elevation
## temp.var 1.0000000 -0.7427028 -0.2262409 -0.3715471
## Precip -0.7427028 1.0000000 -0.1551517 0.1813600
## wind -0.2262409 -0.1551517 1.0000000 0.1052805
## elevation -0.3715471 0.1813600 0.1052805 1.0000000
site.vars2017 <- site.vars
## check for collinearity
vifstep(site.vars, th=10) ## remove potassium and temperature minimum
## No variable from the 4 input variables has collinearity problem.
##
## The linear correlation coefficients ranges between:
## min correlation ( elevation ~ wind ): 0.1052805
## max correlation ( Precip ~ temp.var ): -0.7427028
##
## ---------- VIFs of the remained variables --------
## Variables VIF
## 1 temp.var 3.438786
## 2 Precip 3.035337
## 3 wind 1.402010
## 4 elevation 1.192010
pca2 <- prcomp(log(abs(site.vars)), scale=T)
plot(pca2)
biplot(pca2)
summary(pca2) ## 85% variation explained
## Importance of components:
## PC1 PC2 PC3 PC4
## Standard deviation 1.434 1.0121 0.8809 0.37883
## Proportion of Variance 0.514 0.2561 0.1940 0.03588
## Cumulative Proportion 0.514 0.7701 0.9641 1.00000
## check contribution of loadings
pca2$rotation
## PC1 PC2 PC3 PC4
## temp.var 0.6557532 -0.09123357 0.20565681 0.7206729
## Precip -0.6176537 -0.16891771 -0.40105332 0.6550778
## wind -0.1019884 0.97279862 0.06826009 0.1964733
## elevation -0.4220070 -0.12963831 0.89005734 0.1135866
aload <- abs(pca2$rotation)
sweep(aload, 2, colSums(aload), "/")
## PC1 PC2 PC3 PC4
## temp.var 0.36483385 0.06695609 0.1314078 0.42749339
## Precip 0.34363685 0.12396828 0.2562596 0.38858328
## wind 0.05674213 0.71393442 0.0436159 0.11654531
## elevation 0.23478717 0.09514122 0.5687167 0.06737801
## define gradients
gradient1.season2 <- pca2$x[,1]
gradient2.season2 <- pca2$x[,2]
# crs.world <-CRS("+proj=longlat +datum=WGS84")
# gps <- data.frame(x=site.gps$long,y=site.gps$lat)
# coordinates(gps) <- ~x+y
# proj4string(gps) <- crs.world
#
# ## Download and extract PET/aridity
# r1 <- raster("C:\\Users\\Alessandro\\Downloads\\Global Aridity - Annual\\AI_annual\\ai_yr\\w001001.adf", package="raster") #aridity
# r2 <- raster("C:\\Users\\Alessandro\\Downloads\\Global PET - Annual\\PET_he_annual\\pet_he_yr\\w001001.adf", package="raster") #potential evapotranspiration
# calclim <- stack(r1,r2)
# names(calclim) <- c("aridity","PET")
# arid.vals <- raster::extract(calclim, gps)
# rownames(arid.vals) <- site.gps[,"name"]
# colnames(arid.vals)[1] <- "Gradient"
# write.csv(arid.vals, "Data/aridity.PET.csv")
arid.vals <- read.csv("Data/aridity.PET.csv")
colnames(arid.vals)[1] <- "Site"
par(mfrow=c(1,2))
mean.phyto <- census %>% filter(Census=="end") %>%group_by(Year, Gradient, Site, Microsite) %>% summarise_if(is.numeric, funs(mean(., na.rm=T)))
mean.phyto <- data.frame(mean.phyto)
rii.data <- rii(census, 1:6, var=9:15)
rii.mean <- rii.data %>% group_by(Year, Gradient,Site) %>% summarise_if(is.numeric, funs(mean(., na.rm=T)))
rii.mean <- data.frame(rii.mean)
season1.mean <- season1 %>% group_by(Gradient,Site) %>% summarise(temp.var=var(avg.temp,na.rm=T),Precip=sum(Precip),wind=mean(wind.speed, na.rm=T), max.temp=abs(mean(max.temp, na.rm=T)),min.temp=abs(mean(min.temp, na.rm=T)),avg.temp=abs(mean(avg.temp, na.rm=T)))
s1.mean <- data.frame(season1.mean)
season2.mean <- season2 %>% group_by(Gradient,Site) %>% summarise(temp.var=var(avg.temp,na.rm=T),Precip=sum(Precip, na.rm=T),wind=mean(wind.speed, na.rm=T), max.temp=abs(mean(max.temp, na.rm=T)),min.temp=abs(mean(min.temp, na.rm=T)),avg.temp=abs(mean(avg.temp, na.rm=T)))
s2.mean <- data.frame(season2.mean)
s1.mean[,"arid.gradient"] <- log(s1.mean[,"Precip"]/arid.vals[,"PET"])
s2.mean[,"arid.gradient"] <- log(s2.mean[,"Precip"]/(arid.vals[,"PET"]))
## collect aridity gradient data
site.climate <- rbind(s1.mean,s2.mean)
site.climate[,"Year"] <- as.factor(c(rep("2016",7),rep("2017",7)))
## combine climate data with census
mean.phyto <- merge(mean.phyto , site.climate, by=c("Year","Site"))
phyto.2016 <- subset(mean.phyto, Year==2016)
plot(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"],1), phyto.2016[phyto.2016$Microsite=="open","phyto.biomass"], ylim=c(0,2), ylab=c("all phytometer biomass (g)"), xlab=c("aridity gradient"))
points(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"],2), phyto.2016[phyto.2016$Microsite=="shrub","phyto.biomass"], pch=19)
legend(-4.5,1.8, c("shrub","open"), pch=c(19,1))
text(-2.3, 1.8, "2016", cex=1.5)
plot(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"], rii.mean[rii.mean$Year==2016,"phyto.biomass"], ylim=c(-0.4,0.4), ylab="RII all phytometer biomass", pch=19, xlab=c("aridity gradient"))
text(-2.3, 0.38, "2016", cex=1.5)
phyto.2017 <- subset(mean.phyto, Year==2017)
plot(jitter(phyto.2017[phyto.2017$Microsite=="open","arid.gradient"],1), phyto.2017[phyto.2017$Microsite=="open","phyto.biomass"], ylim=c(0,3), xlab=c("aridity gradient"),ylab=c("all phytometer biomass (g)"))
points(jitter(phyto.2017[phyto.2017$Microsite=="open","arid.gradient"],2), phyto.2017[phyto.2017$Microsite=="shrub","phyto.biomass"], pch=19)
legend(-4.5,1.8, c("shrub","open"), pch=c(19,1))
text(-2.0, 2.8, "2017", cex=1.5)
plot(phyto.2017[phyto.2017$Microsite=="open","arid.gradient"], rii.mean[rii.mean$Year==2017,"phyto.biomass"], ylim=c(-0.4,0.4), ylab="RII all phytometer biomass", pch=19, xlab=c("aridity gradient"))
text(-2.0, 0.38, "2017", cex=1.5)
## regress gradient and microsite on biomass for phytometers in 2016
m1 <- lm(ihs(Phacelia.biomass)~arid.gradient * Microsite, data=phyto.2016)
summary(m1) ## nothing significant
##
## Call:
## lm(formula = ihs(Phacelia.biomass) ~ arid.gradient * Microsite,
## data = phyto.2016)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.26646 -0.16692 0.01821 0.09053 0.43991
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.75896 0.31899 2.379 0.0387 *
## arid.gradient 0.16726 0.09147 1.829 0.0974 .
## Micrositeshrub 0.81930 0.45112 1.816 0.0994 .
## arid.gradient:Micrositeshrub 0.19010 0.12936 1.470 0.1724
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2383 on 10 degrees of freedom
## Multiple R-squared: 0.674, Adjusted R-squared: 0.5762
## F-statistic: 6.893 on 3 and 10 DF, p-value: 0.008498
m2 <- lm(ihs(Plantago.biomass)~arid.gradient * Microsite, data=phyto.2016)
summary(m2) ## nothing significant
##
## Call:
## lm(formula = ihs(Plantago.biomass) ~ arid.gradient * Microsite,
## data = phyto.2016)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.070995 -0.048467 0.003316 0.024049 0.115472
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.27085 0.07901 3.428 0.00646 **
## arid.gradient 0.05886 0.02266 2.598 0.02658 *
## Micrositeshrub -0.12531 0.11174 -1.121 0.28831
## arid.gradient:Micrositeshrub -0.02928 0.03204 -0.914 0.38239
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.05904 on 10 degrees of freedom
## Multiple R-squared: 0.4794, Adjusted R-squared: 0.3232
## F-statistic: 3.069 on 3 and 10 DF, p-value: 0.07774
m3 <- lm(ihs(Salvia.biomass)~arid.gradient * Microsite, data=phyto.2016)
summary(m3)## aridity significant
##
## Call:
## lm(formula = ihs(Salvia.biomass) ~ arid.gradient * Microsite,
## data = phyto.2016)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.15051 -0.09099 -0.01568 0.03332 0.26045
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.748316 0.194293 3.851 0.0032 **
## arid.gradient 0.159284 0.055714 2.859 0.0170 *
## Micrositeshrub -0.000770 0.274771 -0.003 0.9978
## arid.gradient:Micrositeshrub 0.004763 0.078792 0.060 0.9530
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1452 on 10 degrees of freedom
## Multiple R-squared: 0.6281, Adjusted R-squared: 0.5165
## F-statistic: 5.63 on 3 and 10 DF, p-value: 0.01599
## regress gradient and microsite on biomass for phytometers in 2017
m4 <- lm(ihs(Phacelia.biomass)~arid.gradient * Microsite, data=phyto.2017)
summary(m4) ## nothing significant
##
## Call:
## lm(formula = ihs(Phacelia.biomass) ~ arid.gradient * Microsite,
## data = phyto.2017)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.53579 -0.12720 0.00415 0.29889 0.40793
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.725 3.895 -1.727 0.135
## arid.gradient -2.514 1.315 -1.912 0.104
## Micrositeshrub 6.929 4.012 1.727 0.135
## arid.gradient:Micrositeshrub 2.341 1.363 1.718 0.137
##
## Residual standard error: 0.4168 on 6 degrees of freedom
## (4 observations deleted due to missingness)
## Multiple R-squared: 0.3953, Adjusted R-squared: 0.09289
## F-statistic: 1.307 on 3 and 6 DF, p-value: 0.3557
m5 <- lm(ihs(Plantago.biomass)~arid.gradient * Microsite, data=phyto.2017)
summary(m5) ## aridity significant
##
## Call:
## lm(formula = ihs(Plantago.biomass) ~ arid.gradient * Microsite,
## data = phyto.2017)
##
## Residuals:
## 15 16 19 20 23 24 25
## -0.008390 -0.070144 0.006678 -0.031325 0.126617 0.249998 -0.124905
## 26
## -0.148529
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.4847 1.6331 -0.909 0.415
## arid.gradient -0.6486 0.5513 -1.177 0.305
## Micrositeshrub 3.1150 2.3096 1.349 0.249
## arid.gradient:Micrositeshrub 1.1087 0.7796 1.422 0.228
##
## Residual standard error: 0.1748 on 4 degrees of freedom
## (6 observations deleted due to missingness)
## Multiple R-squared: 0.4909, Adjusted R-squared: 0.109
## F-statistic: 1.285 on 3 and 4 DF, p-value: 0.3935
m6 <- lm(ihs(Salvia.biomass)~arid.gradient * Microsite, data=phyto.2017)
summary(m6)## nothing significant
##
## Call:
## lm(formula = ihs(Salvia.biomass) ~ arid.gradient * Microsite,
## data = phyto.2017)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.52276 -0.13176 -0.02786 0.05787 0.53706
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.5442 0.6266 -0.869 0.405
## arid.gradient -0.4200 0.2423 -1.733 0.114
## Micrositeshrub 0.2852 0.8861 0.322 0.754
## arid.gradient:Micrositeshrub 0.1488 0.3427 0.434 0.673
##
## Residual standard error: 0.335 on 10 degrees of freedom
## Multiple R-squared: 0.3112, Adjusted R-squared: 0.1046
## F-statistic: 1.506 on 3 and 10 DF, p-value: 0.2723
#
# ## Phacelia season 1
# plot(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] ,1), phyto.2016[phyto.2016$Microsite=="open","Phacelia.biomass"], ylim=c(0,2))
# points(jitter(phyto.2016[phyto.2016$Microsite=="shrub","arid.gradient"] ,2), phyto.2016[phyto.2016$Microsite=="shrub","Phacelia.biomass"], pch=19)
#
# m1 <- lm(ihs(Phacelia.biomass)~arid.gradient * Microsite, data=phyto.2016)
# m2 <- lm(ihs(Plantago.biomass)~arid.gradient * Microsite, data=phyto.2016)
# m3 <- lm(ihs(Salvia.biomass)~arid.gradient * Microsite, data=phyto.2016)
#
# plot(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] , rii.mean[rii.mean$Year==2016,"Phacelia.biomass"], ylim=c(-0.4,0.4))
#
# ## Plantago season 1
# plot(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] ,1), phyto.2016[phyto.2016$Microsite=="open","Plantago.biomass"], ylim=c(0,2))
# points(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] ,2), phyto.2016[phyto.2016$Microsite=="shrub","Plantago.biomass"], pch=19)
#
# plot(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] , rii.mean[rii.mean$Year==2016,"Plantago.biomass"], ylim=c(-0.4,0.4))
#
# ## Salvia season 1
# plot(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] ,1), phyto.2016[phyto.2016$Microsite=="open","Salvia.biomass"], ylim=c(0,2))
# points(jitter(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] ,2), phyto.2016[phyto.2016$Microsite=="shrub","Salvia.biomass"], pch=19)
#
# plot(phyto.2016[phyto.2016$Microsite=="open","arid.gradient"] , rii.mean[rii.mean$Year==2016,"Salvia.biomass"], ylim=c(-0.4,0.4))
#
#
#
# ## Phacelia season 2
# plot(jitter(gradient1.season2,1), phyto.2017[phyto.2017$Microsite=="open","Phacelia.biomass"], ylim=c(0,2))
# points(jitter(gradient1.season2,2), phyto.2017[phyto.2017$Microsite=="shrub","Phacelia.biomass"], pch=19)
#
# plot(gradient1.season2, rii.mean[rii.mean$Year==2017,"Phacelia.biomass"], ylim=c(-0.4,0.4))
#
#
# ## Plantago season 2
# plot(jitter(gradient1.season2,1), phyto.2017[phyto.2017$Microsite=="open","Plantago.biomass"], ylim=c(0,2))
# points(jitter(gradient1.season2,2), phyto.2017[phyto.2017$Microsite=="shrub","Plantago.biomass"], pch=19)
#
# plot(gradient1.season2, rii.mean[rii.mean$Year==2017,"Plantago.biomass"], ylim=c(-0.4,0.4))
#
# ## Salvia season 2
# plot(jitter(gradient1.season2,1), phyto.2017[phyto.2017$Microsite=="open","Salvia.biomass"], ylim=c(0,2))
# points(jitter(gradient1.season2,2), phyto.2017[phyto.2017$Microsite=="shrub","Salvia.biomass"], pch=19)
#
#
# plot(gradient1.season2, rii.mean[rii.mean$Year==2017,"Salvia.biomass"], ylim=c(-0.4,0.4))
## both seasons
## responses
plot(mean.phyto[mean.phyto$Microsite=="open","arid.gradient"], mean.phyto[mean.phyto$Microsite=="open","phyto.biomass"], ylim=c(0,3), ylab=c("all phytometer biomass (g)"))
points(jitter(mean.phyto[mean.phyto$Microsite=="shrub","arid.gradient"],1), mean.phyto[mean.phyto$Microsite=="shrub","phyto.biomass"], pch=19)
legend(-4.5,2.8, c("shrub","open"), pch=c(19,1))
text(-2.3, 2.8, "both years", cex=1.3)
#
# ## Phacelia
# plot(jitter(mean.phyto[mean.phyto$Microsite=="open","arid.gradient"],1), mean.phyto[mean.phyto$Microsite=="open","Phacelia.biomass"], ylim=c(0,2))
# points(jitter(mean.phyto[mean.phyto$Microsite=="shrub","arid.gradient"],2), mean.phyto[mean.phyto$Microsite=="shrub","Phacelia.biomass"], pch=19)
# m1 <- lm(ihs(Phacelia.biomass) ~ arid.gradient * Microsite, data=mean.phyto)
# summary(m1)
#
# ## Plantago
# plot(jitter(mean.phyto[mean.phyto$Microsite=="open","arid.gradient"],1), mean.phyto[mean.phyto$Microsite=="open","Plantago.biomass"], ylim=c(0,0.5))
# points(jitter(mean.phyto[mean.phyto$Microsite=="shrub","arid.gradient"],2), mean.phyto[mean.phyto$Microsite=="shrub","Plantago.biomass"], pch=19)
# m2 <- lm(ihs(Phacelia.biomass) ~ arid.gradient * Microsite, data=mean.phyto)
# summary(m2)
#
#
# ## Salvia season 1
# plot(jitter(mean.phyto[mean.phyto$Microsite=="open","arid.gradient"],1), mean.phyto[mean.phyto$Microsite=="open","Salvia.biomass"], ylim=c(0,2))
# points(jitter(mean.phyto[mean.phyto$Microsite=="shrub","arid.gradient"],2), mean.phyto[mean.phyto$Microsite=="shrub","Salvia.biomass"], pch=19)
# m3 <- lm(ihs(Salvia.biomass) ~ arid.gradient * Microsite, data=mean.phyto)
# summary(m3)
### Rii plots
rii.mean <- merge(rii.mean, site.climate, by=c("Year","Site"))
## biomass by RII
plot(mean.phyto[mean.phyto$Microsite=="open","Phacelia.biomass"], rii.mean[,"Phacelia.biomass"], ylim=c(-0.3,0.3), pch=19, ylab="RII biomass", xlab="average phytometer biomass per site")
points(mean.phyto[mean.phyto$Microsite=="open","Plantago.biomass"], rii.mean[,"Plantago.biomass"], pch=21, bg="blue")
points(mean.phyto[mean.phyto$Microsite=="open","Salvia.biomass"], rii.mean[,"Salvia.biomass"], pch=21, bg="red")
abline(h=0, lty=2, lwd=2)
legend(0.38,-0.15, c("Phacelia","Plantago","Salvia"), pch=21, pt.bg=c("black","blue","red"))
## rii variability
plot(rii.mean[,"arid.gradient"], rii.mean[,"Phacelia.biomass"], ylim=c(-0.5,0.5), pch=19, ylab="Rii phytometer biomass", xlab="aridity gradient")
points(rii.mean[,"arid.gradient"], rii.mean[,"Plantago.biomass"], pch=21, bg="blue")
points(rii.mean[,"arid.gradient"], rii.mean[,"Salvia.biomass"], pch=21, bg="red")
abline(h=0, lty=2, lwd=2)
legend(-4.5, 0.45, c("Phacelia","Plantago","Salvia"), pch=21, pt.bg=c("black","blue","red"))
## compare convex hull
## hull function
Plot_ConvexHull<-function(xcoord, ycoord, lcolor){
hpts <- chull(x = xcoord, y = ycoord)
hpts <- c(hpts, hpts[1])
lines(xcoord[hpts], ycoord[hpts], col = lcolor)
}
Plot_ConvexHull(xcoord = rii.mean[,"arid.gradient"], ycoord = rii.mean[,"Phacelia.biomass"], lcolor = "black")
Plot_ConvexHull(xcoord = rii.mean[,"arid.gradient"], ycoord = rii.mean[,"Plantago.biomass"], lcolor = "blue")
Plot_ConvexHull(xcoord = rii.mean[,"arid.gradient"], ycoord = rii.mean[,"Salvia.biomass"], lcolor = "red")
r.df <- rii.mean[,c("arid.gradient","Phacelia.biomass","Plantago.biomass","Salvia.biomass")]
## transform data into long format
r.df <- gather(r.df, species, biomass, 2:4)
## function to create a convex hull around data
hull.time <- function(df){
df[chull(df$arid.gradient,df$biomass),] # chull really is useful, even outside of contrived examples.
}
## break data into lists and recombined to apply polygon
splitData <- split(r.df, r.df$species)
appliedData <- lapply(splitData, hull.time)
combinedData <- do.call(rbind, appliedData)
## create polygon
poly1 <- ggplot(r.df, aes(x=arid.gradient, y=biomass))+
geom_polygon(data = combinedData, # This is also a nice example of how to plot
aes(x=arid.gradient, y=biomass, group = species, color=species), fill=NA, # two superimposed geoms
alpha = 1/2) + theme_bw()
poly1
## regress rii on gradient
m1 <- lm(Phacelia.biomass~arid.gradient, data=rii.mean)
summary(m1) ## not significant
##
## Call:
## lm(formula = Phacelia.biomass ~ arid.gradient, data = rii.mean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.022533 -0.013199 -0.005837 0.008594 0.058681
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.038659 0.020960 1.844 0.0899 .
## arid.gradient 0.008913 0.006828 1.305 0.2162
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02266 on 12 degrees of freedom
## Multiple R-squared: 0.1244, Adjusted R-squared: 0.05139
## F-statistic: 1.704 on 1 and 12 DF, p-value: 0.2162
m2 <- lm(Plantago.biomass~arid.gradient, data=rii.mean)
summary(m2) ## not significant
##
## Call:
## lm(formula = Plantago.biomass ~ arid.gradient, data = rii.mean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.030560 -0.002438 0.002575 0.006742 0.019216
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.006458 0.014218 -0.454 0.658
## arid.gradient -0.001721 0.004632 -0.372 0.717
##
## Residual standard error: 0.01537 on 12 degrees of freedom
## Multiple R-squared: 0.01137, Adjusted R-squared: -0.07101
## F-statistic: 0.1381 on 1 and 12 DF, p-value: 0.7167
m3 <- lm(Salvia.biomass~arid.gradient, data=rii.mean)
summary(m3) ## not significant
##
## Call:
## lm(formula = Salvia.biomass ~ arid.gradient, data = rii.mean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.051586 -0.015918 -0.001203 0.007707 0.066895
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.015346 0.029966 -0.512 0.618
## arid.gradient -0.004097 0.009762 -0.420 0.682
##
## Residual standard error: 0.0324 on 12 degrees of freedom
## Multiple R-squared: 0.01447, Adjusted R-squared: -0.06766
## F-statistic: 0.1761 on 1 and 12 DF, p-value: 0.6821
#
# m1 <- lm(Phacelia.biomass~arid.gradient, data=subset(rii.mean,Year == 2016))
# m2 <- lm(Plantago.biomass~arid.gradient, data=subset(rii.mean,Year == 2016))
# m3 <- lm(Salvia.biomass~arid.gradient, data=subset(rii.mean,Year == 2016))
#
#
# m1 <- lm(Phacelia.biomass~arid.gradient, data=subset(rii.mean,Year == 2017))
# m2 <- lm(Plantago.biomass~arid.gradient, data=subset(rii.mean,Year == 2017))
# m3 <- lm(Salvia.biomass~arid.gradient, data=subset(rii.mean,Year == 2017))
#
#
# plot(rii.mean[,"min.temp"], rii.mean[,"Phacelia.biomass"], ylim=c(-0.4,0.4), pch=19)
# points(rii.mean[,"min.temp"], rii.mean[,"Plantago.biomass"], pch=21, bg="blue")
# points(rii.mean[,"min.temp"], rii.mean[,"Salvia.biomass"], pch=21, bg="red")
# abline(h=0, lty=2, lwd=2)
#
# rii.test <- subset(rii.mean, Gradient.x>3 & Year == 2017 | Year == 2016)
#
#
# plot(rii.test[,"arid.gradient"], rii.test[,"Phacelia.biomass"], ylim=c(-0.4,0.4), pch=19)
# points(rii.test[,"arid.gradient"], rii.test[,"Plantago.biomass"], pch=21, bg="blue")
# points(rii.test[,"arid.gradient"], rii.test[,"Salvia.biomass"], pch=21, bg="red")
# abline(h=0, lty=2, lwd=2)
#
#
# plot(rii.mean[,"arid.gradient"], rii.mean[,"Phacelia"], ylim=c(-0.4,0.4), pch=19)
# points(rii.mean[,"arid.gradient"], rii.mean[,"Plantago"], pch=21, bg="blue")
# points(rii.mean[,"arid.gradient"], rii.mean[,"Salvia"], pch=21, bg="red")
# abline(h=0, lty=2, lwd=2)
#
#
# m1 <- lm(Phacelia~ poly(arid.gradient,2), data=rii.mean)
# summary(m1)
# m2 <- lm(Plantago.biomass~arid.gradient, data=rii.mean)
# m3 <- lm(Salvia.biomass~arid.gradient, data=rii.mean)
## join aridity with nutrients
nutrients.climate <- merge(nutrients,subset(site.climate, Year==2016), by=c("Site"))
## Nitrogen difference between shrub and sites
m.nit <- aov(log(N) ~ Site * microsite, data=nutrients)
summary(m.nit)
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 63.04 10.51 13.241 2.86e-09 ***
## microsite 1 40.16 40.16 50.614 2.24e-09 ***
## Site:microsite 6 4.96 0.83 1.042 0.408
## Residuals 56 44.43 0.79
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m.nit, "microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(N) ~ Site * microsite, data = nutrients)
##
## $microsite
## diff lwr upr p adj
## shrub-open 1.514873 1.088317 1.941429 0
## Potassium difference between shrub and sites
m.pot <- aov(log(K) ~ Site * microsite, data=nutrients)
summary(m.pot)
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 15.897 2.650 22.013 4.09e-13 ***
## microsite 1 4.445 4.445 36.934 1.14e-07 ***
## Site:microsite 6 1.605 0.268 2.223 0.0541 .
## Residuals 56 6.740 0.120
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m.pot, "microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(K) ~ Site * microsite, data = nutrients)
##
## $microsite
## diff lwr upr p adj
## shrub-open 0.5040081 0.3378755 0.6701406 1e-07
## Phosphorus difference between shrub and sites
m.pho <- aov(log(P) ~ Site * microsite, data=nutrients)
summary(m.pho)
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 23.163 3.861 14.33 8.10e-10 ***
## microsite 1 10.546 10.546 39.15 5.79e-08 ***
## Site:microsite 6 3.394 0.566 2.10 0.0676 .
## Residuals 56 15.085 0.269
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m.pho, "microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(P) ~ Site * microsite, data = nutrients)
##
## $microsite
## diff lwr upr p adj
## shrub-open 0.7762734 0.5277317 1.024815 1e-07
nutrient.mean <- nutrients.climate %>% group_by(Site, arid.gradient) %>% summarize(nitrogen=mean(N), phosphorus=mean(P), potassium=mean(K))
nutrient.mean <- data.frame(nutrient.mean)
ggplot(nutrient.mean) + geom_jitter(aes(x=arid.gradient, y=nitrogen), color="#E69F00", size=3) + stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=nitrogen), color="#E69F00") + geom_jitter(aes(x=arid.gradient, y=potassium/20), color="#56B4E9", size=3) + stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=potassium/20), color="#56B4E9") + geom_jitter(aes(x=arid.gradient, y=phosphorus), color="#009E73", size=3) +ylab("soil nutrient content")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16)) + xlab("aridity gradient")+
annotate("segment", x = -4.5, xend = -4.35, y = 25, yend = 25, colour = "#E69F00", size=2) + ## add custom legend
annotate("text", x = -4.3, y = 25, label = "Nitrogen", size=5, hjust=0)+
annotate("segment", x = -4.5, xend = -4.35, y = 23, yend = 23, colour = "#56B4E9", size=2) + ## add custom legend
annotate("text", x = -4.3, y = 23, label = "Potassium", size=5, hjust=0)+
annotate("segment", x = -4.5, xend = -4.35, y = 21, yend = 21, colour = "#009E73", size=2) + ## add custom legend
annotate("text", x = -4.3, y = 21, label = "Phosphorus", size=5, hjust=0)
m1 <- lm(nitrogen~poly(arid.gradient,2), data=nutrient.mean)
summary(m1)
##
## Call:
## lm(formula = nitrogen ~ poly(arid.gradient, 2), data = nutrient.mean)
##
## Residuals:
## 1 2 3 4 5 6 7
## 1.1092 1.0570 -0.4565 -0.8511 -0.8789 -0.3757 0.3960
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.4326 0.3942 13.782 0.000161 ***
## poly(arid.gradient, 2)1 -12.6364 1.0429 -12.116 0.000266 ***
## poly(arid.gradient, 2)2 7.0832 1.0429 6.792 0.002454 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.043 on 4 degrees of freedom
## Multiple R-squared: 0.9797, Adjusted R-squared: 0.9695
## F-statistic: 96.47 on 2 and 4 DF, p-value: 0.0004126
m2 <- lm(phosphorus~arid.gradient, data=nutrient.mean)
summary(m2)
##
## Call:
## lm(formula = phosphorus ~ arid.gradient, data = nutrient.mean)
##
## Residuals:
## 1 2 3 4 5 6 7
## 4.3035 1.1485 -2.0485 1.1930 -0.2791 -5.5020 1.1845
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.191 4.527 3.135 0.0258 *
## arid.gradient 1.780 1.298 1.371 0.2287
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.383 on 5 degrees of freedom
## Multiple R-squared: 0.2732, Adjusted R-squared: 0.1278
## F-statistic: 1.879 on 1 and 5 DF, p-value: 0.2287
m3 <- lm(potassium~poly(arid.gradient,2), data=nutrient.mean)
summary(m3)
##
## Call:
## lm(formula = potassium ~ poly(arid.gradient, 2), data = nutrient.mean)
##
## Residuals:
## 1 2 3 4 5 6 7
## -3.551 -65.927 32.611 57.492 -25.220 52.524 -47.931
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 186.56 22.69 8.221 0.00119 **
## poly(arid.gradient, 2)1 189.58 60.04 3.157 0.03427 *
## poly(arid.gradient, 2)2 190.31 60.04 3.170 0.03387 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 60.04 on 4 degrees of freedom
## Multiple R-squared: 0.8334, Adjusted R-squared: 0.7502
## F-statistic: 10.01 on 2 and 4 DF, p-value: 0.02774
spp.data <- read.csv("Data/ERG.communitydata.csv")
spp.data[is.na(spp.data)] <- 0
mean.spp <- spp.data %>% group_by(Year,Site, Microsite) %>% summarize(abd=mean(Abundance), richness=mean(Richness), biomass=mean(Biomass))
mean.spp <- data.frame(mean.spp)
## collect aridity gradient data
site.climate <- rbind(s1.mean,s2.mean)
site.climate[,"Year"] <- c(rep("2016",7),rep("2017",7))
## combine climate data with community data
mean.spp <- merge(mean.spp, site.climate, by.y=c("Year","Site"))
# ## community responses season1
# mean.spp2016 <- subset(mean.spp, Year==2016)
#
# ## richness
# plot(mean.spp2016[mean.spp2016$Microsite=="open","arid.gradient"], mean.spp2016[mean.spp2016$Microsite=="open","richness"], ylab="average site richness", xlab="aridity gradient")
# points(mean.spp2016[mean.spp2016$Microsite=="shrub","arid.gradient"],mean.spp2016[mean.spp2016$Microsite=="shrub","richness"], pch=19)
#
# m1 <- lm(richness~arid.gradient*Microsite, data=mean.spp2016)
# summary(m1)
#
# ## abundance
# plot(mean.spp2016[mean.spp2016$Microsite=="open","arid.gradient"], mean.spp2016[mean.spp2016$Microsite=="open","abd"], ylab="average site abundance", xlab="aridity gradient")
# points(mean.spp2016[mean.spp2016$Microsite=="shrub","arid.gradient"],mean.spp2016[mean.spp2016$Microsite=="shrub","abd"], pch=19)
#
# m2 <- lm(abd~arid.gradient*Microsite, data=mean.spp2016)
# summary(m2)
#
# ## biomass
# plot(mean.spp2016[mean.spp2016$Microsite=="open","arid.gradient"], mean.spp2016[mean.spp2016$Microsite=="open","biomass"], ylab="average site biomass", xlab="aridity gradient")
# points(mean.spp2016[mean.spp2016$Microsite=="shrub","arid.gradient"],mean.spp2016[mean.spp2016$Microsite=="shrub","biomass"], pch=19)
#
# m3 <- lm(biomass~arid.gradient*Microsite, data=mean.spp2016)
# summary(m3)
#
# ##season2
#
# ## community responses season2
#
# mean.spp2017 <- subset(mean.spp, Year==2017)
#
#
# ## richness
# plot(mean.spp2017[mean.spp2017$Microsite=="open","arid.gradient"], mean.spp2017[mean.spp2017$Microsite=="open","richness"])
# points(mean.spp2017[mean.spp2017$Microsite=="shrub","arid.gradient"],mean.spp2017[mean.spp2017$Microsite=="shrub","richness"], pch=19)
#
# m1 <- lm(richness~arid.gradient*Microsite, data=mean.spp2017)
# summary(m1)
#
# ## abundance
# plot(mean.spp2017[mean.spp2017$Microsite=="open","arid.gradient"], mean.spp2017[mean.spp2017$Microsite=="open","abd"])
# points(mean.spp2017[mean.spp2017$Microsite=="shrub","arid.gradient"],mean.spp2017[mean.spp2017$Microsite=="shrub","abd"], pch=19)
#
# m2 <- lm(abd~arid.gradient*Microsite, data=mean.spp2017)
# summary(m2)
#
# ## biomass
# plot(mean.spp2017[mean.spp2017$Microsite=="open","arid.gradient"], mean.spp2017[mean.spp2017$Microsite=="open","biomass"])
# points(mean.spp2017[mean.spp2017$Microsite=="shrub","arid.gradient"],mean.spp2017[mean.spp2017$Microsite=="shrub","biomass"], pch=19)
#
# m3 <- lm(biomass~arid.gradient*Microsite, data=mean.spp2017)
# summary(m3)
## both seasons
## richness
plot(mean.spp[mean.spp$Microsite=="open","arid.gradient"], mean.spp[mean.spp$Microsite=="open","richness"], ylab="average site richness", xlab="aridity gradient")
points(mean.spp[mean.spp$Microsite=="shrub","arid.gradient"],mean.spp[mean.spp$Microsite=="shrub","richness"], pch=19)
m1 <- lm(richness~arid.gradient*Microsite, data=mean.spp)
summary(m1)
##
## Call:
## lm(formula = richness ~ arid.gradient * Microsite, data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.56169 -0.66225 -0.07639 0.66154 1.76433
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.9206 0.8381 5.871 4.68e-06 ***
## arid.gradient 0.8699 0.2730 3.186 0.00397 **
## Micrositeshrub -1.8968 1.1852 -1.600 0.12260
## arid.gradient:Micrositeshrub -0.5531 0.3861 -1.432 0.16490
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9061 on 24 degrees of freedom
## Multiple R-squared: 0.3356, Adjusted R-squared: 0.2526
## F-statistic: 4.042 on 3 and 24 DF, p-value: 0.01849
m1 <- lm(richness~poly(arid.gradient,2), data=mean.spp)
summary(m1)
##
## Call:
## lm(formula = richness ~ poly(arid.gradient, 2), data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.09400 -0.58831 -0.06033 0.47242 1.63726
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.2286 0.1418 15.719 1.81e-14 ***
## poly(arid.gradient, 2)1 2.7847 0.7502 3.712 0.001034 **
## poly(arid.gradient, 2)2 -2.7989 0.7502 -3.731 0.000986 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7502 on 25 degrees of freedom
## Multiple R-squared: 0.5256, Adjusted R-squared: 0.4876
## F-statistic: 13.85 on 2 and 25 DF, p-value: 8.954e-05
ggplot(mean.spp) + geom_jitter(aes(x=arid.gradient, y=richness, fill=Microsite, color=Microsite), size=3) +
scale_color_manual(values=c("#E69F00","#56B4E9")) + stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=richness), color="black")+ ylab("Species richness") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
## abundance
plot(mean.spp[mean.spp$Microsite=="open","arid.gradient"], mean.spp[mean.spp$Microsite=="open","abd"], ylab="average site abundance", xlab="aridity gradient")
points(mean.spp[mean.spp$Microsite=="shrub","arid.gradient"],mean.spp[mean.spp$Microsite=="shrub","abd"], pch=19)
m2 <- lm(abd~arid.gradient*Microsite, data=mean.spp)
summary(m2)
##
## Call:
## lm(formula = abd ~ arid.gradient * Microsite, data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -64.997 -26.611 -5.081 25.895 108.541
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 162.65 38.28 4.249 0.00028 ***
## arid.gradient 41.28 12.47 3.310 0.00294 **
## Micrositeshrub 39.22 54.14 0.724 0.47582
## arid.gradient:Micrositeshrub 10.04 17.64 0.569 0.57457
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 41.39 on 24 degrees of freedom
## Multiple R-squared: 0.5409, Adjusted R-squared: 0.4835
## F-statistic: 9.426 on 3 and 24 DF, p-value: 0.000268
m2 <- lm(ihs(abd)~arid.gradient, data=mean.spp)
summary(m2)
##
## Call:
## lm(formula = ihs(abd) ~ arid.gradient, data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.18927 -0.43160 -0.06177 0.41813 1.50236
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.6323 0.4214 20.48 < 2e-16 ***
## arid.gradient 1.7161 0.1373 12.50 1.69e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6444 on 26 degrees of freedom
## Multiple R-squared: 0.8573, Adjusted R-squared: 0.8519
## F-statistic: 156.3 on 1 and 26 DF, p-value: 1.687e-12
ggplot(mean.spp) + geom_jitter(aes(x=arid.gradient, y=ihs(abd), fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9")) + stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=ihs(abd)), color="black")+ ylab("Annual abundance") + xlab("aridity gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
## biomass
plot(mean.spp[mean.spp$Microsite=="open","arid.gradient"], ihs(mean.spp[mean.spp$Microsite=="open","biomass"]), ylab="average site biomass", xlab="aridity gradient")
points(mean.spp[mean.spp$Microsite=="shrub","arid.gradient"],ihs(mean.spp[mean.spp$Microsite=="shrub","biomass"]), pch=19)
m3 <- lm(ihs(biomass)~arid.gradient*Microsite, data=mean.spp)
summary(m3)
##
## Call:
## lm(formula = ihs(biomass) ~ arid.gradient * Microsite, data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.6596 -0.5085 -0.0684 0.3314 1.2077
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.6251 0.5577 4.707 8.75e-05 ***
## arid.gradient 0.5873 0.1817 3.233 0.00355 **
## Micrositeshrub 1.6603 0.7888 2.105 0.04596 *
## arid.gradient:Micrositeshrub 0.3698 0.2569 1.439 0.16303
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.603 on 24 degrees of freedom
## Multiple R-squared: 0.6498, Adjusted R-squared: 0.606
## F-statistic: 14.84 on 3 and 24 DF, p-value: 1.128e-05
ggplot(mean.spp) + geom_jitter(aes(x=arid.gradient, y=ihs(biomass), fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+ stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=ihs(biomass)), color="#56B4E9", data=subset(mean.spp, Microsite=="shrub")) + stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=ihs(biomass)), data=subset(mean.spp, Microsite=="open"), color="#E69F00")+ ylab("Annual biomass") + xlab("aridity gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
community <- read.csv("Data/ERG.communitydata.csv")
community[is.na(community)] <- 0
##2016
## add enviro data to dataframe
comm2016 <- subset(community, Year==2016)
site.vars2016[,"Site"] <- as.factor(row.names(site.vars2016))
comm2016 <- merge(comm2016, site.vars2016, by="Site")
## transform spp data
community.trans <- decostand(comm2016[,13:53], "hellinger")
rda1 <- rda(community.trans, comm2016[,54:57])
(R2adj <- RsquareAdj(rda1)$adj.r.squared) ## 50.4% of variation explained
## [1] 0.3871872
## build byplot manually
par(mar=c(4.5,4.5,0.5,0.5))
plot(rda1, type="n", xlim=c(-1,1), ylim=c(-1.5,1.5))
## calculate priority
spp.priority <- colSums(comm2016[,13:53])
## plot RDA1
colvec <- rep(c("blue","dodgerblue3","cyan","yellow2","orange","tomato","red2"),each=60)
points(rda1, display = "sites", col = "black", pch = c(21), bg = colvec)
orditorp(rda1, display = "species", cex = 0.7, col = "darkred", priority=spp.priority, air=0.5)
text(rda1, display = "bp", col = "blue", cex = 0.8)
legend("bottomright", pch=c(21), legend=unique(comm2016$Site), pt.bg=unique(colvec), cex=1)
## ordikplot to adjust species locations
## 2017
## add enviro data to dataframe
comm2017 <- subset(community, Year==2017)
site.vars[,"Site"] <- as.factor(row.names(site.vars))
comm2017 <- merge(comm2017, site.vars, by="Site")
#
# ## transform spp data
# community.trans <- decostand(comm2017[,13:53], "hellinger")
#
# rda2 <- rda(community.trans, comm2017[,54:58])
# (R2adj <- RsquareAdj(rda2)$adj.r.squared) ## 50.4% of variation explained
#
#
# ## build byplot manually
# par(mar=c(4.5,4.5,0.5,0.5))
# plot(rda2, type="n", xlim=c(-1,1), ylim=c(-1.5,1.5))
#
# ## calculate priority
# spp.priority <- colSums(comm2017[,13:53])
#
# ## plot RDA2
# colvec <- rep(c("blue","dodgerblue3","cyan","yellow2","orange","tomato","red2"),each=60)
# points(rda2, display = "sites", col = "black", pch = c(21), bg = colvec)
# orditorp(rda2, display = "species", cex = 0.7, col = "darkred", priority=spp.priority, air=0.5)
# text(rda2, display = "bp", col = "blue", cex = 0.8)
# legend("bottomright", pch=c(21), legend=unique(comm2016$Site), pt.bg=unique(colvec), cex=1)
# ## ordikplot to adjust species locations
census <- read.csv("Data/ERG.phytometer.census.csv")
census[is.na(census)] <- 0
census[,"phyto.abd"] <- rowSums(census[,c("Phacelia","Plantago","Salvia")])
## calculate the number of seeds per gram
seed.mass <- read.csv("Data/seed.mass.csv")
seed.mass.avg <- seed.mass %>% group_by(species) %>% summarize(avg.seed.gram=mean(seed.number),se.seed.gram=se(seed.number))
seed.mass.avg <- data.frame(seed.mass.avg)
seed.mass.avg
## species avg.seed.gram se.seed.gram
## 1 Amsinkia 235.2 7.611833
## 2 Caulanthus 3019.0 8.916277
## 3 Lipidium 752.4 4.261455
## 4 Monolopia 737.8 7.831986
## 5 Phacelia 772.0 5.300943
## 6 Plantago 558.2 6.865858
## 7 Salvia 980.0 9.612492
## get proportion of seed germinated per 0.3 grams of seed
census[,"Phacelia.prop"] <- census[,"Phacelia"]/(seed.mass.avg$avg.seed.gram[which(seed.mass.avg$species=="Phacelia")]*0.3)
census[,"Plantago.prop"] <- census[,"Plantago"]/(seed.mass.avg$avg.seed.gram[which(seed.mass.avg$species=="Plantago")]*0.3)
census[,"Salvia.prop"] <- census[,"Salvia"]/(seed.mass.avg$avg.seed.gram[which(seed.mass.avg$species=="Salvia")]*0.3)
## beginning
census.int <- subset(census, Census=="emergence")
## all species
m1 <- glm.nb(Phacelia~ Microsite * Nutrient * Site + Year, data=census.int)
anova(m1, test="Chisq") ## Site * Micro and Year significant
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.8108), link: log
##
## Response: Phacelia
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 1079.71
## Microsite 1 10.304 838 1069.41 0.001328 **
## Nutrient 1 1.234 837 1068.17 0.266538
## Site 6 159.651 831 908.52 < 2.2e-16 ***
## Year 1 31.424 830 877.10 2.073e-08 ***
## Microsite:Nutrient 1 0.046 829 877.05 0.829874
## Microsite:Site 6 21.032 823 856.02 0.001811 **
## Nutrient:Site 6 5.542 817 850.48 0.476389
## Microsite:Nutrient:Site 6 8.030 811 842.45 0.235879
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Phacelia
m1 <- glm.nb(Phacelia~ Microsite * Nutrient * Site + Year, data=census.int)
anova(m1, test="Chisq") ## Site * Micro and Year significant
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.8108), link: log
##
## Response: Phacelia
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 1079.71
## Microsite 1 10.304 838 1069.41 0.001328 **
## Nutrient 1 1.234 837 1068.17 0.266538
## Site 6 159.651 831 908.52 < 2.2e-16 ***
## Year 1 31.424 830 877.10 2.073e-08 ***
## Microsite:Nutrient 1 0.046 829 877.05 0.829874
## Microsite:Site 6 21.032 823 856.02 0.001811 **
## Nutrient:Site 6 5.542 817 850.48 0.476389
## Microsite:Nutrient:Site 6 8.030 811 842.45 0.235879
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Plantago
m2 <- glm.nb(Plantago~ Microsite * Nutrient * Site + Year, data=census.int)
anova(m2, test="Chisq") ## Site * Micro and Year significant
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.5335), link: log
##
## Response: Plantago
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 984.30
## Microsite 1 6.256 838 978.04 0.01238 *
## Nutrient 1 1.060 837 976.98 0.30332
## Site 6 162.687 831 814.30 < 2.2e-16 ***
## Year 1 4.138 830 810.16 0.04194 *
## Microsite:Nutrient 1 2.388 829 807.77 0.12224
## Microsite:Site 6 43.000 823 764.77 1.167e-07 ***
## Nutrient:Site 6 6.391 817 758.38 0.38088
## Microsite:Nutrient:Site 6 4.615 811 753.77 0.59403
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Salvia
m3 <- glm.nb(Salvia~ Microsite * Nutrient * Site + Year, data=census.int)
anova(m3, test="Chisq") ## Site * Micro and Year significant + (micro x nutrient)
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.8273), link: log
##
## Response: Salvia
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 1210.25
## Microsite 1 5.924 838 1204.33 0.0149386 *
## Nutrient 1 1.513 837 1202.82 0.2186678
## Site 6 211.625 831 991.19 < 2.2e-16 ***
## Year 1 17.463 830 973.73 2.929e-05 ***
## Microsite:Nutrient 1 7.824 829 965.90 0.0051548 **
## Microsite:Site 6 26.421 823 939.48 0.0001858 ***
## Nutrient:Site 6 4.587 817 934.90 0.5977624
## Microsite:Nutrient:Site 6 1.566 811 933.33 0.9549811
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
census.int.plot <- gather(census.int, species, abundance, Phacelia:Salvia)
##calculate confidence interval
census.plot<- census.int.plot %>% group_by(Microsite, species, Site, Year) %>% summarize(avg=mean(abundance),ci=se(abundance)*1.96)
ggplot(census.plot, aes(x=Microsite, y=avg, fill=species))+
geom_bar(position=position_dodge(), stat="identity")+
geom_errorbar(aes(ymin=avg-ci, ymax=avg+ci),
width=.2, # Width of the error bars
position=position_dodge(.9))+ scale_fill_brewer() +ylab("Abundance")+ theme_Publication() + facet_grid(Year~Site)
## end season
census.end <- subset(census, Census=="end")
census.end[,"Year"] <- as.factor(census.end$Year)
## run full model for phyto biomass
m1 <- aov(log(phyto.biomass)~ Site * Microsite * Nutrient + Year, data=subset(census.end, phyto.biomass>0))
summary(m1)
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 330.8 55.13 32.164 < 2e-16 ***
## Microsite 1 10.9 10.88 6.347 0.012127 *
## Nutrient 1 30.3 30.25 17.651 3.24e-05 ***
## Year 1 161.2 161.21 94.051 < 2e-16 ***
## Site:Microsite 6 23.9 3.99 2.327 0.031940 *
## Site:Nutrient 6 41.9 6.98 4.073 0.000551 ***
## Microsite:Nutrient 1 1.7 1.73 1.011 0.315196
## Site:Microsite:Nutrient 6 7.9 1.32 0.768 0.595068
## Residuals 424 726.7 1.71
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m1, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(phyto.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, phyto.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.3096905 0.06750868 0.5518722 0.0123243
## all species end of season
m2 <- glm.nb(phyto.abd~ Microsite * Nutrient * Site + Year, data=census.end)
anova(m2, test="Chisq") ## Site and microsite*nutrient significant
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.455), link: log
##
## Response: phyto.abd
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 1009.51
## Microsite 1 1.059 838 1008.45 0.30341
## Nutrient 1 2.527 837 1005.92 0.11194
## Site 6 135.420 831 870.50 < 2e-16 ***
## Year 1 3.412 830 867.09 0.06474 .
## Microsite:Nutrient 1 4.586 829 862.50 0.03224 *
## Microsite:Site 6 5.340 823 857.16 0.50104
## Nutrient:Site 6 5.169 817 852.00 0.52238
## Microsite:Nutrient:Site 6 5.683 811 846.31 0.45956
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## run full model for phacelia biomass
m3 <- aov(log(Phacelia.biomass)~ Site * Microsite * Nutrient + Year, data=subset(census.end, Phacelia.biomass>0))
summary(m3) ## site and microsite
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 89.7 14.95 8.274 4.95e-08 ***
## Microsite 1 21.2 21.20 11.738 0.00074 ***
## Nutrient 1 10.2 10.19 5.642 0.01845 *
## Year 1 95.5 95.49 52.857 7.42e-12 ***
## Site:Microsite 6 23.6 3.93 2.173 0.04692 *
## Site:Nutrient 6 8.0 1.34 0.742 0.61612
## Microsite:Nutrient 1 0.0 0.00 0.001 0.97552
## Site:Microsite:Nutrient 5 4.1 0.82 0.452 0.81122
## Residuals 205 370.3 1.81
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m3, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Phacelia.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, Phacelia.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.6312547 0.2667053 0.9958041 0.0007714
## run full model for plantago biomass
m4 <- aov(log(Plantago.biomass)~ Site * Microsite * Nutrient + Year, data=subset(census.end, Plantago.biomass>0))
summary(m4) ## site and year + sitexmicrosite
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 116.35 19.39 19.843 2.32e-16 ***
## Microsite 1 1.96 1.96 2.001 0.160
## Nutrient 1 32.03 32.03 32.778 6.80e-08 ***
## Year 1 138.38 138.38 141.597 < 2e-16 ***
## Site:Microsite 6 4.87 0.81 0.830 0.549
## Site:Nutrient 4 1.99 0.50 0.508 0.730
## Microsite:Nutrient 1 3.17 3.17 3.244 0.074 .
## Site:Microsite:Nutrient 3 0.65 0.22 0.220 0.882
## Residuals 130 127.05 0.98
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m4, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Plantago.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, Plantago.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open -0.2179629 -0.5348829 0.0989571 0.1759823
## run full model for plantago biomass
m5 <- aov(log(Salvia.biomass)~ Site * Microsite * Nutrient + Year, data=subset(census.end, Salvia.biomass>0))
summary(m5) ## site and year + sitexmicrosite
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 170.1 28.35 19.982 < 2e-16 ***
## Microsite 1 0.0 0.01 0.008 0.929221
## Nutrient 1 21.4 21.43 15.103 0.000124 ***
## Year 1 44.1 44.05 31.045 5.39e-08 ***
## Site:Microsite 6 6.8 1.14 0.802 0.568988
## Site:Nutrient 6 46.2 7.70 5.424 2.35e-05 ***
## Microsite:Nutrient 1 0.5 0.55 0.387 0.534459
## Site:Microsite:Nutrient 6 12.9 2.16 1.520 0.171069
## Residuals 317 449.8 1.42
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m5, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Salvia.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, Salvia.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.01133515 -0.2406604 0.2633307 0.9295351
## run full model for phacelia abundance
m6 <- glm.nb(Phacelia.biomass~ Site * Microsite * Nutrient + Year, data=subset(census.end, Phacelia>0))
summary(m3) ## site and microsite
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 89.7 14.95 8.274 4.95e-08 ***
## Microsite 1 21.2 21.20 11.738 0.00074 ***
## Nutrient 1 10.2 10.19 5.642 0.01845 *
## Year 1 95.5 95.49 52.857 7.42e-12 ***
## Site:Microsite 6 23.6 3.93 2.173 0.04692 *
## Site:Nutrient 6 8.0 1.34 0.742 0.61612
## Microsite:Nutrient 1 0.0 0.00 0.001 0.97552
## Site:Microsite:Nutrient 5 4.1 0.82 0.452 0.81122
## Residuals 205 370.3 1.81
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m3, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Phacelia.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, Phacelia.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.6312547 0.2667053 0.9958041 0.0007714
## run full model for plantago biomass
m7 <- aov(log(Plantago)~ Site * Microsite * Nutrient + Year, data=subset(census.end, Plantago>0))
summary(m4) ## site and year + sitexmicrosite
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 116.35 19.39 19.843 2.32e-16 ***
## Microsite 1 1.96 1.96 2.001 0.160
## Nutrient 1 32.03 32.03 32.778 6.80e-08 ***
## Year 1 138.38 138.38 141.597 < 2e-16 ***
## Site:Microsite 6 4.87 0.81 0.830 0.549
## Site:Nutrient 4 1.99 0.50 0.508 0.730
## Microsite:Nutrient 1 3.17 3.17 3.244 0.074 .
## Site:Microsite:Nutrient 3 0.65 0.22 0.220 0.882
## Residuals 130 127.05 0.98
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m4, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Plantago.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, Plantago.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open -0.2179629 -0.5348829 0.0989571 0.1759823
## run full model for plantago biomass
m8 <- aov(log(Salvia)~ Site * Microsite * Nutrient + Year, data=subset(census.end, Salvia>0))
summary(m5) ## site and year + sitexmicrosite
## Df Sum Sq Mean Sq F value Pr(>F)
## Site 6 170.1 28.35 19.982 < 2e-16 ***
## Microsite 1 0.0 0.01 0.008 0.929221
## Nutrient 1 21.4 21.43 15.103 0.000124 ***
## Year 1 44.1 44.05 31.045 5.39e-08 ***
## Site:Microsite 6 6.8 1.14 0.802 0.568988
## Site:Nutrient 6 46.2 7.70 5.424 2.35e-05 ***
## Microsite:Nutrient 1 0.5 0.55 0.387 0.534459
## Site:Microsite:Nutrient 6 12.9 2.16 1.520 0.171069
## Residuals 317 449.8 1.42
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m5, "Microsite")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Salvia.biomass) ~ Site * Microsite * Nutrient + Year, data = subset(census.end, Salvia.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.01133515 -0.2406604 0.2633307 0.9295351
census.end.plot <- gather(census.end, species, biomass, Phacelia.biomass:Salvia.biomass)
##calculate confidence interval
census.plot<- census.end.plot %>% group_by(Microsite, species, Site, Year) %>% summarize(avg=mean(biomass),ci=se(biomass)*1.96)
ggplot(census.plot, aes(x=Microsite, y=avg, fill=species))+
geom_bar(position=position_dodge(), stat="identity")+
geom_errorbar(aes(ymin=avg-ci, ymax=avg+ci),
width=.2, # Width of the error bars
position=position_dodge(.9))+ scale_fill_brewer() +ylab("Abundance")+ theme_Publication() + facet_grid(Year~Site)
### RDA
#
# ##collect environmental variables for site
# nutrients <- read.csv("Data/ERG.soilnutrients.csv")
# nutrients.mean <- nutrients %>% group_by(gradient,site, microsite) %>% summarise_each(funs(mean))
# nutrients.vars <- data.frame(nutrients.mean)
#
# ## minimum explanation of variables
# ambient2016[is.na(ambient2016)] <- 0
# community <- ambient2016 %>% group_by(Gradient,Site, Microsite) %>% summarise_each(funs(sum))
# community <- data.frame(community)
#
# end.census <- subset(census2016, census=="end")
# end.census <- end.census %>% group_by(Gradient,Site, Microsite) %>% summarise_each(funs(mean))
# end.census<- data.frame(end.census)
#
# ## daily means
# day.mean <- aggregate(HOBO.data, by=list(day=HOBO.data$Day, micro=HOBO.data$Microsite, site=HOBO.data$Site), mean)
#
# ## summarize daily means across sites
# means <- day.mean %>% group_by(gradient, micro) %>% summarize(temp=mean(Temp),rh=mean(RH),temp.se=se(Temp),rh.se=se(RH))
# means <- data.frame(means)
#
#
# envs <- data.frame(swc=end.census[,"swc"],nutrients.vars[,c("N","P","K")], means[,c("temp","rh")])
#
# ## hellinger transformation
# community.trans <- decostand(community[,12:42], "hellinger")
#
# ## rda with environmental variables
# rda1 <- rda(community.trans, envs)
# anova(rda1)
# (R2adj <- RsquareAdj(rda1)$adj.r.squared) ## 25.7% of variation explained
#
#
# ## build byplot manually
# par(mar=c(4.5,4.5,0.5,0.5))
# plot(rda1, type="n", xlim=c(-1,1))
#
# with(community, levels(Site))
#
# spp.priority <- colSums(community[,12:42])
#
# colvec <- c("blue","dodgerblue3","cyan","yellow2","orange","tomato","red2")
# with(community, points(rda1, display = "sites", col = "black", pch = c(21,22), bg = colvec[Site]))
# orditorp(rda1, display = "species", cex = 0.7, col = "darkred", priority=spp.priority, air=1,)
# text(rda1, display = "bp", col = "blue", cex = 0.8)
# legend("bottomright", pch=c(21), legend=community$Site[community$Microsite=="shrub"], pt.bg=colvec, cex=1)
#
# ## check variable explanation
# vif.cca(rda1)
#
# v.clim <- cbind(envs[,c("temp","rh")])
# v.nut <- cbind(envs[,c("N","P","K")])
# v.swc <- envs[,"swc"]
#
# x <- varpart(community.trans,v.clim,v.nut,v.swc)
#
# showvarparts(3)
library(bootES)
## Loading required package: boot
##
## Attaching package: 'boot'
## The following object is masked from 'package:lattice':
##
## melanoma
effect.cal <- function(x){ bootES(x, R=999, data.col="Biomass", group.col="Microsite", contrast=c(shrub=1,open=-1), effect.type=c("cohens.d"))}
effect.site <- by(subset(comm2016, Site != "Barstow"), comm2016$Site[comm2016$Site != "Barstow"], FUN=effect.cal)
site.summary <- rbind(summary(effect.site$Panoche),summary(effect.site$Cuyama),summary(effect.site$TejonRanch),data.frame(stat=0,ci.low=0,ci.high=0,bias=0,std.error=0),summary(effect.site$MojavePreserve),summary(effect.site$SheepholeValley),summary(effect.site$Tecopa))
site.summary[5,] <- 0
site.summary <- sapply(site.summary, as.numeric)
par(mar=c(4.5,4.5,.5,.5))
plot(c(1:7),site.summary[,"stat"], xlim=c(0.5,7.5), ylim=c(-1,3), pch=19, cex=1.4, ylab="Hedge's G", xlab="", xaxt="n")
arrows(c(1:7),as.numeric(site.summary[,"ci.high"]),c(1:7),site.summary[,"ci.low"], angle=90, code=3, length=0, lwd=2)
abline(h=0, lty=2, lwd=2)
axis(1, c(1:7), labels=site.names, cex.axis=1)
## phytometer
effect.cal <- function(x){ bootES(x, R=999, data.col="phyto.biomass", group.col="Microsite", contrast=c(shrub=1,open=-1), effect.type=c("cohens.d"))}
census2016 <- subset(census, Census=="end" & Year ==2016)
effect.site <- by(subset(census2016, Site != "Barstow"), census2016$Site[census2016$Site != "Barstow"], FUN=effect.cal)
site.summary <- rbind(summary(effect.site$Panoche),summary(effect.site$Cuyama),summary(effect.site$TejonRanch),data.frame(stat=0,ci.low=0,ci.high=0,bias=0,std.error=0),summary(effect.site$MojavePreserve),summary(effect.site$SheepholeValley),summary(effect.site$Tecopa))
site.summary <- sapply(site.summary, as.numeric)
par(mar=c(4.5,4.5,.5,.5))
plot(c(1:7),site.summary[,"stat"], xlim=c(0.5,7.5), ylim=c(-1,3), pch=19, cex=1.4, ylab="Hedge's G", xlab="", xaxt="n")
arrows(c(1:7),site.summary[,"ci.high"],c(1:7),site.summary[,"ci.low"], angle=90, code=3, length=0, lwd=2)
abline(h=0, lty=2, lwd=2)
axis(1, c(1:7), labels=site.names, cex.axis=1)
rii.dat <- rii(community, j=1:8, var=c("Abundance","Richness","Biomass"))
rii.mean <- rii.dat %>% group_by(Year, Gradient, Site) %>% summarize(avg=mean(Biomass),se=se(Biomass))
rii.mean <- data.frame(rii.mean)
plot(rii.mean[rii.mean$Year==2016,"Gradient"]-.1,rii.mean[rii.mean$Year==2016,"avg"], ylim=c(-1,1), pch=19, cex=1.5, xlim=c(0.5,7.5), ylab="Rii Biomass", xlab="Site", xaxt="n", cex.lab=1.5)
axis(1, 1:7, lab=unique(rii.mean$Site))
error.bar(rii.mean[rii.mean$Year==2016,"Gradient"]-.1,rii.mean[rii.mean$Year==2016,"avg"],rii.mean[rii.mean$Year==2016,"se"])
error.bar(rii.mean[rii.mean$Year==2017,"Gradient"]+.1,rii.mean[rii.mean$Year==2017,"avg"],rii.mean[rii.mean$Year==2017,"se"])
points(rii.mean[rii.mean$Year==2017,"Gradient"]+.1,rii.mean[rii.mean$Year==2017,"avg"], pch=21, bg="Grey50", cex=1.5)
abline(h=0, lwd=2, lty=2)
legend(6.3,-0.55, c("2016","2017"), pch=22, pt.bg=c("Black","Grey50"), cex=1.6)
## add year column to precipitation data
precip[,"Year"] <- ifelse(precip$season=="season.1","2016","2017")
rii.precip <- merge(precip,rii.mean, by=c("Year","Gradient"))
## load species list
spp.list <- read.csv("Data/ERG.specieslist.csv")
## convert data to long format
status <- gather(community, species, abundance, 13:53)
names(spp.list)[1] <- "species" ## rename species column for merge
## combine native-non-native status with data set
status <- merge(status, spp.list, by="species")
## summarize per plot native and non-natives, convert back to wide format
mean.status <- status %>% group_by(Year, Site, Microsite, Rep, status) %>% summarize(abundance=sum(abundance))
mean.status <- spread(mean.status, status, abundance)
## calculate site means for native and non-native
mean.status <- mean.status %>% group_by(Year, Site, Microsite) %>% summarize(native=mean(native), non.native=mean(non.native))
## merge with original community data
mean.spp <- merge(mean.spp, mean.status, by=c("Year","Site","Microsite"))
## native
m1 <- lm(ihs(native) ~ poly(arid.gradient,2), data=subset(mean.spp, Microsite=="shrub"))
summary(m1)
##
## Call:
## lm(formula = ihs(native) ~ poly(arid.gradient, 2), data = subset(mean.spp,
## Microsite == "shrub"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.03332 -0.65782 -0.04555 0.60465 1.25478
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.6533 0.2185 7.565 1.11e-05 ***
## poly(arid.gradient, 2)1 0.3447 0.8177 0.422 0.68145
## poly(arid.gradient, 2)2 -2.9468 0.8177 -3.604 0.00414 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8177 on 11 degrees of freedom
## Multiple R-squared: 0.5448, Adjusted R-squared: 0.4621
## F-statistic: 6.583 on 2 and 11 DF, p-value: 0.01318
m1 <- lm(ihs(native) ~ arid.gradient, data=subset(mean.spp, Microsite=="open"))
summary(m1)
##
## Call:
## lm(formula = ihs(native) ~ arid.gradient, data = subset(mean.spp,
## Microsite == "open"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.89497 -0.73527 0.02181 0.50785 1.81716
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.0097 1.0111 3.966 0.00187 **
## arid.gradient 0.6575 0.3294 1.996 0.06913 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.093 on 12 degrees of freedom
## Multiple R-squared: 0.2493, Adjusted R-squared: 0.1867
## F-statistic: 3.984 on 1 and 12 DF, p-value: 0.06913
m1 <- lm(ihs(native) ~ poly(arid.gradient,2)*Microsite, data=mean.spp)
summary(m1)
##
## Call:
## lm(formula = ihs(native) ~ poly(arid.gradient, 2) * Microsite,
## data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.6483 -0.6647 -0.1444 0.5383 2.0863
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 2.0776 0.2616 7.943
## poly(arid.gradient, 2)1 3.0858 1.3841 2.229
## poly(arid.gradient, 2)2 -1.1145 1.3841 -0.805
## Micrositeshrub -0.4243 0.3699 -1.147
## poly(arid.gradient, 2)1:Micrositeshrub -2.5983 1.9574 -1.327
## poly(arid.gradient, 2)2:Micrositeshrub -3.0529 1.9574 -1.560
## Pr(>|t|)
## (Intercept) 6.65e-08 ***
## poly(arid.gradient, 2)1 0.0363 *
## poly(arid.gradient, 2)2 0.4293
## Micrositeshrub 0.2637
## poly(arid.gradient, 2)1:Micrositeshrub 0.1980
## poly(arid.gradient, 2)2:Micrositeshrub 0.1331
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9787 on 22 degrees of freedom
## Multiple R-squared: 0.4229, Adjusted R-squared: 0.2918
## F-statistic: 3.225 on 5 and 22 DF, p-value: 0.0247
ggplot(mean.spp) + geom_jitter(aes(x=arid.gradient, y=ihs(native), fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+ stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=ihs(native)), color="black")+ ylab("Native abundance") + xlab("aridity gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
## non-native
m1 <- lm(ihs(non.native) ~ poly(arid.gradient,2), data=subset(mean.spp, Microsite=="shrub"))
summary(m1)
##
## Call:
## lm(formula = ihs(non.native) ~ poly(arid.gradient, 2), data = subset(mean.spp,
## Microsite == "shrub"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.32477 -0.20348 -0.05303 0.53297 2.27555
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.0777 0.3340 9.214 1.66e-06 ***
## poly(arid.gradient, 2)1 6.5874 1.2498 5.271 0.000264 ***
## poly(arid.gradient, 2)2 0.7721 1.2498 0.618 0.549292
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.25 on 11 degrees of freedom
## Multiple R-squared: 0.7191, Adjusted R-squared: 0.668
## F-statistic: 14.08 on 2 and 11 DF, p-value: 0.0009268
m1 <- lm(ihs(non.native) ~ poly(arid.gradient,2), data=subset(mean.spp, Microsite=="open"))
summary(m1)
##
## Call:
## lm(formula = ihs(non.native) ~ poly(arid.gradient, 2), data = subset(mean.spp,
## Microsite == "open"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.66301 -0.60211 0.01432 0.55858 1.91804
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.8844 0.2828 10.200 6.06e-07 ***
## poly(arid.gradient, 2)1 6.1497 1.0581 5.812 0.000117 ***
## poly(arid.gradient, 2)2 0.4615 1.0581 0.436 0.671141
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.058 on 11 degrees of freedom
## Multiple R-squared: 0.7554, Adjusted R-squared: 0.7109
## F-statistic: 16.98 on 2 and 11 DF, p-value: 0.0004331
m1 <- lm(ihs(non.native) ~ poly(arid.gradient,2)*Microsite, data=mean.spp)
summary(m1)
##
## Call:
## lm(formula = ihs(non.native) ~ poly(arid.gradient, 2) * Microsite,
## data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.32477 -0.43001 -0.01113 0.58589 2.27555
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 2.8844 0.3095 9.320
## poly(arid.gradient, 2)1 8.6970 1.6376 5.311
## poly(arid.gradient, 2)2 0.6527 1.6376 0.399
## Micrositeshrub 0.1933 0.4377 0.442
## poly(arid.gradient, 2)1:Micrositeshrub 0.6190 2.3159 0.267
## poly(arid.gradient, 2)2:Micrositeshrub 0.4393 2.3159 0.190
## Pr(>|t|)
## (Intercept) 4.28e-09 ***
## poly(arid.gradient, 2)1 2.49e-05 ***
## poly(arid.gradient, 2)2 0.694
## Micrositeshrub 0.663
## poly(arid.gradient, 2)1:Micrositeshrub 0.792
## poly(arid.gradient, 2)2:Micrositeshrub 0.851
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.158 on 22 degrees of freedom
## Multiple R-squared: 0.7361, Adjusted R-squared: 0.6761
## F-statistic: 12.27 on 5 and 22 DF, p-value: 9.2e-06
m1 <- lm(ihs(non.native) ~ arid.gradient*Microsite, data=mean.spp)
summary(m1)
##
## Call:
## lm(formula = ihs(non.native) ~ arid.gradient * Microsite, data = mean.spp)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.5300 -0.4742 0.1206 0.7847 2.0747
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.3299 1.0394 8.014 3.06e-08 ***
## arid.gradient 1.8530 0.3386 5.472 1.26e-05 ***
## Micrositeshrub 0.5808 1.4699 0.395 0.696
## arid.gradient:Micrositeshrub 0.1319 0.4789 0.275 0.785
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.124 on 24 degrees of freedom
## Multiple R-squared: 0.7289, Adjusted R-squared: 0.695
## F-statistic: 21.51 on 3 and 24 DF, p-value: 5.506e-07
ggplot(mean.spp) + geom_jitter(aes(x=arid.gradient, y=ihs(non.native), fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+ stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=ihs(non.native)), color="black")+ ylab("Non-native abundance") + xlab("aridity gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
library(picante)
library(ape)
library(brranching)
library(taxize)
## load species list to create tree
spp.list <- read.csv("Data/ERG.specieslist.csv")
## create a combined species name column and drop erinoginum because not to species level
taxa <- paste(spp.list$Genus, spp.list$Species.name)
taxa <- taxa[taxa!="Erinoginum spp"]
## create tree of phylogeny
tree <- phylomatic(taxa=taxa, get = 'POST')
## calculate branch lengths using Grafen's method
## Grafen, A. (1989) The phylogenetic regression. Philosophical Transactions of the Royal society of London. Series B. Biological Sciences, 326, 119–157.
tree2 <- compute.brlen(tree, method="Grafen")
## view tree and outputs to verify branches
plot(tree2)
tree2
##
## Phylogenetic tree with 39 tips and 29 internal nodes.
##
## Tip labels:
## cryptantha_barbigera, cryptantha_intermedia, phacelia_crenulata, phacelia_tanacetifolia, pectocarya_spp, amsinckia_grandiflora, ...
## Node labels:
## poales_to_asterales, eudicots, , , asterids, ericales_to_asterales, ...
##
## Rooted; includes branch lengths.
## format community to only have site and microsite
comm <- community %>% group_by(Year, Site, Microsite) %>% summarise_if(is.numeric, funs(sum(., na.rm=T)))
comm <- comm[,c(1:3,13:53)] ## extract species abundances only
comm <- data.frame(comm) ## convert to dataframe
comm[,"site.micro"] <- paste(comm$Site,comm$Microsite,as.character(comm$Year)) ## create site by microsite column
rownames(comm) <- comm[,length(comm)] ## replace row names with site by microsite
comm[,c("Year","Site","Microsite","Erinoginum.spp","Boraginaceae.sp.","site.micro")] <- NULL ## drop all columns but ones for analysis
## match species name format
spp.list[,"spp.name"] <- paste(spp.list$Genus, spp.list$Species.name)
colnames(comm) <- spp.list$spp.name[match(colnames(comm), spp.list$Species.shorthand)]
## match species format
names(comm) <- gsub(" ", "_", names(comm), fixed=T) ## underscores instead of spaces
names(comm) <- gsub("__", "_", names(comm), fixed=T) ## replace double underscores with one
names(comm) <- tolower(names(comm)) ## lower case names
## mean phylogenetic distance
mpd.data <- mpd(comm, cophenetic(tree2), abundance.weighted=T)
## format dataframe
mpd.data <- data.frame(Year=c(rep(2016,14),rep(2017,14)),Microsite=c("open","shrub"),site=rownames(comm), mpd=mpd.data)
mpd.data[,"Site"] <- gsub(" open", "", mpd.data[,"site"])
mpd.data[,"Site"] <- gsub(" shrub", "", mpd.data[,"Site"])
mpd.data[,"Site"] <- gsub(" 2016", "", mpd.data[,"Site"])
mpd.data[,"Site"] <- gsub(" 2017", "", mpd.data[,"Site"])
mpd.data[,"site"] <- NULL
mpd.data[is.na(mpd.data)] <- 0 ## barstow no plants
## getspecies richness for sites
spp.rich <- community %>% group_by(Year, Site, Microsite) %>% summarize(richness=mean(Richness))
spp.rich <- data.frame(spp.rich)
## join data
mpd.rich <- merge(mpd.data, spp.rich, by=c("Site","Microsite","Year"))
mpd.arid <- merge(mpd.rich, mean.spp, by=c("Site","Microsite","Year"))
## phylogenetic distance
mpd.arid <- mpd.arid[c(2,4:nrow(mpd.arid)),] ## drop barstow
m1 <- lm(mpd~arid.gradient*Microsite, data=mpd.arid)
summary(m1)
##
## Call:
## lm(formula = mpd ~ arid.gradient * Microsite, data = mpd.arid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.51050 -0.19590 0.06299 0.14972 0.71607
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.97618 0.30321 3.219 0.00395 **
## arid.gradient 0.04716 0.10394 0.454 0.65451
## Micrositeshrub -1.07891 0.42881 -2.516 0.01966 *
## arid.gradient:Micrositeshrub -0.30441 0.14700 -2.071 0.05031 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2938 on 22 degrees of freedom
## Multiple R-squared: 0.3146, Adjusted R-squared: 0.2211
## F-statistic: 3.365 on 3 and 22 DF, p-value: 0.03692
ggplot(mpd.arid) + geom_jitter(aes(x=arid.gradient, y=mpd, fill=Microsite, color=Microsite), size=3) +
scale_color_manual(values=c("#E69F00","#56B4E9")) + stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=mpd), data=subset(mpd.arid, Microsite=="shrub"), color="#56B4E9")+ stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=mpd), data=subset(mpd.arid, Microsite=="open"), color="#E69F00")+ ylab("Phylogenetic Community Dissimilarity") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m1 <- lm(mpd~arid.gradient, data=subset(mpd.arid, Microsite=="shrub"))
summary(m1)
##
## Call:
## lm(formula = mpd ~ arid.gradient, data = subset(mpd.arid, Microsite ==
## "shrub"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.51050 -0.23112 0.03664 0.14204 0.71607
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.1027 0.3563 -0.288 0.778
## arid.gradient -0.2573 0.1222 -2.106 0.059 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3452 on 11 degrees of freedom
## Multiple R-squared: 0.2873, Adjusted R-squared: 0.2225
## F-statistic: 4.435 on 1 and 11 DF, p-value: 0.05899
m2 <- lm(mpd~arid.gradient, data=subset(mpd.arid, Microsite=="open"))
summary(m2)
##
## Call:
## lm(formula = mpd ~ arid.gradient, data = subset(mpd.arid, Microsite ==
## "open"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.38078 -0.09025 0.08952 0.15668 0.33783
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.97618 0.23852 4.093 0.00178 **
## arid.gradient 0.04716 0.08177 0.577 0.57575
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2311 on 11 degrees of freedom
## Multiple R-squared: 0.02935, Adjusted R-squared: -0.05889
## F-statistic: 0.3326 on 1 and 11 DF, p-value: 0.5758
### Nutrients
nutrient.mean <- nutrients.climate %>% group_by(Site, arid.gradient, microsite) %>% summarize(nitrogen=mean(N), phosphorus=mean(P), potassium=mean(K))
nutrient.mean <- data.frame(nutrient.mean)
## nitrogen
m1 <- lm(nitrogen ~ arid.gradient, data=subset(nutrient.mean, microsite=="open"))
summary(m1)
##
## Call:
## lm(formula = nitrogen ~ arid.gradient, data = subset(nutrient.mean,
## microsite == "open"))
##
## Residuals:
## 1 3 5 7 9 11 13
## 1.62742 0.10479 -1.35216 0.97441 -0.05162 -0.76608 -0.53677
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.7141 1.5041 -1.804 0.1310
## arid.gradient -1.2879 0.4313 -2.986 0.0306 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.124 on 5 degrees of freedom
## Multiple R-squared: 0.6407, Adjusted R-squared: 0.5689
## F-statistic: 8.917 on 1 and 5 DF, p-value: 0.03058
anova(m1)
## Analysis of Variance Table
##
## Response: nitrogen
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 11.263 11.263 8.9174 0.03058 *
## Residuals 5 6.315 1.263
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ggplot(nutrient.mean) + geom_jitter(aes(x=arid.gradient, y=nitrogen, fill=microsite, color=microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9")) +
stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=nitrogen), color="#56B4E9", data=subset(nutrient.mean, microsite=="shrub")) +
stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=nitrogen), color="#E69F00", data=subset(nutrient.mean, microsite=="open"))+ ylab("Nitrogen") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
## phosphorus
m2 <- lm(phosphorus ~ arid.gradient * microsite, data=nutrient.mean)
summary(m2)
##
## Call:
## lm(formula = phosphorus ~ arid.gradient * microsite, data = nutrient.mean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.1684 -2.3472 0.6103 1.9735 7.0340
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.8933 5.3802 1.653 0.129
## arid.gradient 0.7555 1.5428 0.490 0.635
## micrositeshrub 10.5952 7.6088 1.392 0.194
## arid.gradient:micrositeshrub 2.0483 2.1819 0.939 0.370
##
## Residual standard error: 4.02 on 10 degrees of freedom
## Multiple R-squared: 0.3967, Adjusted R-squared: 0.2158
## F-statistic: 2.192 on 3 and 10 DF, p-value: 0.152
anova(m2)
## Analysis of Variance Table
##
## Response: phosphorus
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 43.011 43.011 2.6614 0.1339
## microsite 1 49.031 49.031 3.0339 0.1122
## arid.gradient:microsite 1 14.243 14.243 0.8813 0.3700
## Residuals 10 161.610 16.161
ggplot(nutrient.mean) + geom_jitter(aes(x=arid.gradient, y=phosphorus, fill=microsite, color=microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9")) ## not significant
m3 <- lm(potassium ~ arid.gradient * microsite, data=nutrient.mean)
summary(m3)
##
## Call:
## lm(formula = potassium ~ arid.gradient * microsite, data = nutrient.mean)
##
## Residuals:
## Min 1Q Median 3Q Max
## -160.67 -64.64 -14.22 64.63 206.92
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 290.78 145.57 1.998 0.0737 .
## arid.gradient 44.64 41.74 1.069 0.3101
## micrositeshrub 278.33 205.87 1.352 0.2062
## arid.gradient:micrositeshrub 56.24 59.03 0.953 0.3633
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 108.8 on 10 degrees of freedom
## Multiple R-squared: 0.4843, Adjusted R-squared: 0.3295
## F-statistic: 3.13 on 3 and 10 DF, p-value: 0.07444
anova(m3)
## Analysis of Variance Table
##
## Response: potassium
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 71879 71879 6.0754 0.0334 *
## microsite 1 28476 28476 2.4069 0.1519
## arid.gradient:microsite 1 10736 10736 0.9074 0.3633
## Residuals 10 118313 11831
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## potassium
ggplot(nutrient.mean) + geom_jitter(aes(x=arid.gradient, y=potassium, fill=microsite, color=microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9")) +
stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=potassium), color="black")
#### Shrubs increase nitrogen availability at aridity extremes #### Shrubs do not effect potassium or phosphorus availability
se <- function(x) sd(na.omit(x))/sqrt(length(na.omit(x)))
smc <- census %>% group_by(Year, Site, Microsite, Census) %>% summarize(swc.avg=mean(swc), swc.se=se(swc))
smc.arid <- merge(smc, site.climate, by=c("Site","Year"))
## early swc
smc.early <- subset(smc.arid, Census=="emergence")
ggplot(smc.early) + geom_jitter(aes(x=arid.gradient, y=swc.avg, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=swc.avg), color="black") + ylab("Percent soil Moisture Content (emergence)") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m1 <- lm(swc.avg~ poly(arid.gradient,2) * Microsite, data=smc.early)
summary(m1)
##
## Call:
## lm(formula = swc.avg ~ poly(arid.gradient, 2) * Microsite, data = smc.early)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.8989 -2.2340 0.1864 2.2093 8.7293
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 11.1650 1.3550 8.240
## poly(arid.gradient, 2)1 32.2475 7.1700 4.498
## poly(arid.gradient, 2)2 20.8675 7.1700 2.910
## Micrositeshrub -0.4679 1.9163 -0.244
## poly(arid.gradient, 2)1:Micrositeshrub -3.3904 10.1399 -0.334
## poly(arid.gradient, 2)2:Micrositeshrub -3.1002 10.1399 -0.306
## Pr(>|t|)
## (Intercept) 3.6e-08 ***
## poly(arid.gradient, 2)1 0.000179 ***
## poly(arid.gradient, 2)2 0.008109 **
## Micrositeshrub 0.809376
## poly(arid.gradient, 2)1:Micrositeshrub 0.741276
## poly(arid.gradient, 2)2:Micrositeshrub 0.762672
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.07 on 22 degrees of freedom
## Multiple R-squared: 0.699, Adjusted R-squared: 0.6306
## F-statistic: 10.22 on 5 and 22 DF, p-value: 3.647e-05
## end swc
smc.end <- subset(smc.arid, Census=="end")
ggplot(smc.end) + geom_jitter(aes(x=arid.gradient, y=swc.avg, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=swc.avg), color="black") + ylab("Percent soil Moisture Content (end)") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m1 <- lm(swc.avg~ poly(arid.gradient,2) * Microsite, data=smc.end)
summary(m1)
##
## Call:
## lm(formula = swc.avg ~ poly(arid.gradient, 2) * Microsite, data = smc.end)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.7611 -2.4087 0.0009 2.0666 9.3760
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 5.093 1.335 3.815
## poly(arid.gradient, 2)1 15.502 7.065 2.194
## poly(arid.gradient, 2)2 17.571 7.065 2.487
## Micrositeshrub -0.576 1.888 -0.305
## poly(arid.gradient, 2)1:Micrositeshrub -1.945 9.991 -0.195
## poly(arid.gradient, 2)2:Micrositeshrub -3.453 9.991 -0.346
## Pr(>|t|)
## (Intercept) 0.000946 ***
## poly(arid.gradient, 2)1 0.039073 *
## poly(arid.gradient, 2)2 0.020948 *
## Micrositeshrub 0.763211
## poly(arid.gradient, 2)1:Micrositeshrub 0.847426
## poly(arid.gradient, 2)2:Micrositeshrub 0.732914
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.996 on 22 degrees of freedom
## Multiple R-squared: 0.4604, Adjusted R-squared: 0.3377
## F-statistic: 3.754 on 5 and 22 DF, p-value: 0.01312
hobo.means <- HOBO.data %>% group_by(season, Microsite, Site) %>% summarize(temp.avg=mean(Temp),temp.var=var(Temp),temp.se=se(Temp),rh.avg=mean(RH, na.rm=T),rh.var=var(RH, na.rm=T),rh.se=se(RH),frost=(sum(na.omit(Temp)<0)/length(na.omit(Temp))*100),heat=(sum(na.omit(Temp)>30)/length(na.omit(Temp))*100))
hobo.means[,"Year"] <- c(rep(2016,14),rep(2017,14))
hobo.arid <- merge(hobo.means, site.climate, by=c("Site","Year"))
## temperature
ggplot(hobo.arid) + geom_jitter(aes(x=arid.gradient, y=temp.avg, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~poly(x,2),aes(x=arid.gradient, y=temp.avg), color="black") + ylab("Average Temperature (C°)") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m1 <- lm(temp.avg~arid.gradient * Microsite, data=hobo.arid)
summary(m1)
##
## Call:
## lm(formula = temp.avg ~ arid.gradient * Microsite, data = hobo.arid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.2362 -0.7204 -0.3884 0.4197 3.2981
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.21950 1.38277 4.498 0.000149 ***
## arid.gradient -1.75909 0.45045 -3.905 0.000669 ***
## Micrositeshrub -1.42763 1.95554 -0.730 0.472428
## arid.gradient:Micrositeshrub 0.00911 0.63704 0.014 0.988709
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.495 on 24 degrees of freedom
## Multiple R-squared: 0.6064, Adjusted R-squared: 0.5571
## F-statistic: 12.32 on 3 and 24 DF, p-value: 4.451e-05
anova(m1)
## Analysis of Variance Table
##
## Response: temp.avg
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 67.815 67.815 30.3425 1.154e-05 ***
## Microsite 1 14.807 14.807 6.6252 0.01666 *
## arid.gradient:Microsite 1 0.000 0.000 0.0002 0.98871
## Residuals 24 53.639 2.235
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
m1.s <- lm(temp.avg~arid.gradient, data=subset(hobo.arid, Microsite=="shrub"))
summary(m1.s)
##
## Call:
## lm(formula = temp.avg ~ arid.gradient, data = subset(hobo.arid,
## Microsite == "shrub"))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.5836 -0.9458 -0.4008 0.4122 3.2981
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.7919 1.3727 3.491 0.00446 **
## arid.gradient -1.7500 0.4472 -3.913 0.00206 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.484 on 12 degrees of freedom
## Multiple R-squared: 0.5607, Adjusted R-squared: 0.5241
## F-statistic: 15.31 on 1 and 12 DF, p-value: 0.00206
## RH
ggplot(hobo.arid) + geom_jitter(aes(x=arid.gradient, y=rh.avg, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=rh.avg), color="black") + ylab("Relative Humidity (%)") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m2 <- lm(log(rh.avg)~arid.gradient * Microsite, data=hobo.arid)
summary(m2)
##
## Call:
## lm(formula = log(rh.avg) ~ arid.gradient * Microsite, data = hobo.arid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.313369 -0.094086 0.008993 0.111107 0.252701
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.703640 0.165465 28.427 < 2e-16 ***
## arid.gradient 0.251051 0.053902 4.658 9.92e-05 ***
## Micrositeshrub 0.049072 0.234003 0.210 0.836
## arid.gradient:Micrositeshrub 0.004987 0.076229 0.065 0.948
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1789 on 24 degrees of freedom
## Multiple R-squared: 0.6497, Adjusted R-squared: 0.6059
## F-statistic: 14.84 on 3 and 24 DF, p-value: 1.131e-05
anova(m2)
## Analysis of Variance Table
##
## Response: log(rh.avg)
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 1.41614 1.41614 44.2510 7.014e-07 ***
## Microsite 1 0.00829 0.00829 0.2591 0.6154
## arid.gradient:Microsite 1 0.00014 0.00014 0.0043 0.9484
## Residuals 24 0.76806 0.03200
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## frost
hobo.arid2 <- subset(hobo.arid, Site!="Cuyama") ## drop cuyama because abnormal frost periods
ggplot(hobo.arid2) + geom_jitter(aes(x=arid.gradient, y=frost, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~x,aes(x=arid.gradient, y=frost), color="black") + ylab("Number of frost days") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m3 <- lm(frost~arid.gradient * Microsite, data=hobo.arid2)
summary(m3)
##
## Call:
## lm(formula = frost ~ arid.gradient * Microsite, data = hobo.arid2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.2695 -1.3394 -0.3817 1.9954 3.3744
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.7896 2.2613 4.771 0.000116 ***
## arid.gradient 1.4999 0.7049 2.128 0.045970 *
## Micrositeshrub -2.3006 3.1980 -0.719 0.480218
## arid.gradient:Micrositeshrub -0.3756 0.9969 -0.377 0.710319
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.117 on 20 degrees of freedom
## Multiple R-squared: 0.3059, Adjusted R-squared: 0.2018
## F-statistic: 2.938 on 3 and 20 DF, p-value: 0.05818
anova(m3)
## Analysis of Variance Table
##
## Response: frost
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 31.066 31.0655 6.9304 0.01596 *
## Microsite 1 7.806 7.8058 1.7414 0.20187
## arid.gradient:Microsite 1 0.636 0.6363 0.1419 0.71032
## Residuals 20 89.649 4.4825
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## temperature variability
ggplot(hobo.arid) + geom_jitter(aes(x=arid.gradient, y=temp.var.x, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=temp.var.x), color="#E69F00", data=subset(hobo.arid, Microsite=="open")) + ylab("Number of frost days")+
stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=temp.var.x), color="#56B4E9", data=subset(hobo.arid, Microsite=="shrub")) + ylab("temperature variation") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m4 <- lm(log(temp.var.x)~arid.gradient * Microsite, data=hobo.arid)
summary(m4)
##
## Call:
## lm(formula = log(temp.var.x) ~ arid.gradient * Microsite, data = hobo.arid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.75540 -0.15564 0.02433 0.17182 0.46013
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.83222 0.26061 14.705 1.67e-13 ***
## arid.gradient -0.19133 0.08490 -2.254 0.0336 *
## Micrositeshrub -0.46416 0.36856 -1.259 0.2200
## arid.gradient:Micrositeshrub -0.02535 0.12006 -0.211 0.8346
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2818 on 24 degrees of freedom
## Multiple R-squared: 0.51, Adjusted R-squared: 0.4488
## F-statistic: 8.327 on 3 and 24 DF, p-value: 0.0005707
anova(m4)
## Analysis of Variance Table
##
## Response: log(temp.var.x)
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 0.91677 0.91677 11.5480 0.002368 **
## Microsite 1 1.06294 1.06294 13.3892 0.001241 **
## arid.gradient:Microsite 1 0.00354 0.00354 0.0446 0.834588
## Residuals 24 1.90531 0.07939
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## extreme heat
## reverse inverse hyperbolic sine
hs <- function(x) {
y <- 0.5*exp(-x)*(exp(2*x)-1)
return(y)
}
ggplot(hobo.arid) + geom_jitter(aes(x=arid.gradient, y=heat, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+
stat_smooth(method="lm", formula= y~hs(x),aes(x=arid.gradient, y=heat), color="#E69F00", data=subset(hobo.arid, Microsite=="open")) +
stat_smooth(method="lm", formula= y~hs(x),aes(x=arid.gradient, y=heat), color="#56B4E9", data=subset(hobo.arid, Microsite=="shrub")) + ylab("extreme heat days variation") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m5 <- lm(ihs(heat)~arid.gradient * Microsite, data=hobo.arid)
summary(m5)
##
## Call:
## lm(formula = ihs(heat) ~ arid.gradient * Microsite, data = hobo.arid)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7532 -0.3832 -0.1102 0.2072 1.2432
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.2199 0.4899 -0.449 0.657489
## arid.gradient -0.7396 0.1596 -4.635 0.000105 ***
## Micrositeshrub -0.1480 0.6928 -0.214 0.832615
## arid.gradient:Micrositeshrub 0.1787 0.2257 0.792 0.436163
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5296 on 24 degrees of freedom
## Multiple R-squared: 0.6529, Adjusted R-squared: 0.6095
## F-statistic: 15.05 on 3 and 24 DF, p-value: 1.015e-05
anova(m5)
## Analysis of Variance Table
##
## Response: ihs(heat)
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 9.3144 9.3144 33.2088 6.124e-06 ***
## Microsite 1 3.1726 3.1726 11.3114 0.00258 **
## arid.gradient:Microsite 1 0.1759 0.1759 0.6271 0.43616
## Residuals 24 6.7315 0.2805
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
shrubz <- read.csv("Data/ERG.shrub.csv")
shrub.mean <- shrubz %>% group_by(Site, Microsite) %>% summarize(compact=mean(Compaction))
shrub.clim <- merge(shrub.mean, site.climate, by=c("Site"))
#shrub.clim <- subset(shrub.clim, Year==2016)
ggplot(shrub.clim) + geom_jitter(aes(x=arid.gradient, y=compact, fill=Microsite, color=Microsite), size=3)+
scale_color_manual(values=c("#E69F00","#56B4E9"))+ stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=compact), color="#E69F00", data=subset(shrub.clim, Microsite=="open"))+
stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=compact), color="#56B4E9", data=subset(shrub.clim, Microsite=="shrub")) + ylab("soil compaction") + xlab("Aridity Gradient")+ theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),axis.line = element_line(colour = "black"),panel.background = element_blank(),axis.text=element_text(size=14),axis.title=element_text(size=16))
m1 <- lm(log(compact) ~ arid.gradient* Microsite, data=shrub.clim)
summary(m1)
##
## Call:
## lm(formula = log(compact) ~ arid.gradient * Microsite, data = shrub.clim)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.36122 -0.13659 -0.02823 0.05479 0.61368
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.26645 0.23301 1.144 0.26410
## arid.gradient -0.07328 0.07590 -0.965 0.34394
## Micrositeshrub -1.19983 0.32952 -3.641 0.00130 **
## arid.gradient:Micrositeshrub -0.32933 0.10734 -3.068 0.00528 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2519 on 24 degrees of freedom
## Multiple R-squared: 0.5932, Adjusted R-squared: 0.5424
## F-statistic: 11.67 on 3 and 24 DF, p-value: 6.53e-05
anova(m1)
## Analysis of Variance Table
##
## Response: log(compact)
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 1.24730 1.24730 19.6548 0.0001755 ***
## Microsite 1 0.37672 0.37672 5.9362 0.0226248 *
## arid.gradient:Microsite 1 0.59733 0.59733 9.4127 0.0052769 **
## Residuals 24 1.52305 0.06346
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(lsmeans)
## The 'lsmeans' package is being deprecated.
## Users are encouraged to switch to 'emmeans'.
## See help('transition') for more information, including how
## to convert 'lsmeans' objects and scripts to work with 'emmeans'.
census.arid <- merge(census.end, site.climate, by=c("Year","Site"))
## all species end of season
m1 <- glm.nb(phyto.abd~ Microsite * Nutrient * arid.gradient, data=census.arid)
anova(m2, test="Chisq") ## Site and microsite*nutrient significant
## Analysis of Variance Table
##
## Response: log(rh.avg)
## Df Sum Sq Mean Sq F value Pr(>F)
## arid.gradient 1 1.41614 1.41614 44.2510 7.014e-07 ***
## Microsite 1 0.00829 0.00829 0.2591 0.6154
## arid.gradient:Microsite 1 0.00014 0.00014 0.0043 0.9484
## Residuals 24 0.76806 0.03200
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## run full model for phacelia biomass
m1 <- aov(log(Phacelia.biomass)~ Microsite * Nutrient * arid.gradient, data=subset(census.arid, Phacelia.biomass>0))
summary(m1) ## site and microsite
## Df Sum Sq Mean Sq F value Pr(>F)
## Microsite 1 19.0 19.00 9.126 0.00281 **
## Nutrient 1 8.8 8.76 4.207 0.04141 *
## arid.gradient 1 122.7 122.66 58.927 4.95e-13 ***
## Microsite:Nutrient 1 0.2 0.16 0.078 0.78078
## Microsite:arid.gradient 1 1.4 1.41 0.678 0.41121
## Nutrient:arid.gradient 1 0.0 0.00 0.000 0.99128
## Microsite:Nutrient:arid.gradient 1 2.3 2.27 1.088 0.29795
## Residuals 225 468.3 2.08
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m1, "Microsite")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Nutrient, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, Nutrient, arid.gradient
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Phacelia.biomass) ~ Microsite * Nutrient * arid.gradient, data = subset(census.arid, Phacelia.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.5995862 0.2084783 0.9906941 0.0028111
TukeyHSD(m1, "Nutrient")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Nutrient, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, Nutrient, arid.gradient
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Phacelia.biomass) ~ Microsite * Nutrient * arid.gradient, data = subset(census.arid, Phacelia.biomass > 0))
##
## $Nutrient
## diff lwr upr p adj
## Ambient-Added -0.3865601 -0.7590709 -0.01404918 0.0420304
## run full model for plantago biomass
m2 <- aov(log(Plantago.biomass)~ Microsite * Nutrient * arid.gradient, data=subset(census.arid, Plantago.biomass>0))
summary(m2) ## site and year + sitexmicrosite
## Df Sum Sq Mean Sq F value Pr(>F)
## Microsite 1 9.59 9.59 5.718 0.018067 *
## Nutrient 1 26.14 26.14 15.582 0.000122 ***
## arid.gradient 1 136.39 136.39 81.293 1.01e-15 ***
## Microsite:Nutrient 1 0.61 0.61 0.366 0.546337
## Microsite:arid.gradient 1 1.57 1.57 0.937 0.334540
## Nutrient:arid.gradient 1 3.96 3.96 2.362 0.126491
## Microsite:Nutrient:arid.gradient 1 3.21 3.21 1.912 0.168873
## Residuals 146 244.96 1.68
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m2, "Microsite")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Nutrient, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, Nutrient, arid.gradient
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Plantago.biomass) ~ Microsite * Nutrient * arid.gradient, data = subset(census.arid, Plantago.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open -0.5018942 -0.9167114 -0.08707699 0.0180668
TukeyHSD(m2, "Nutrient")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Nutrient, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, Nutrient, arid.gradient
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Plantago.biomass) ~ Microsite * Nutrient * arid.gradient, data = subset(census.arid, Plantago.biomass > 0))
##
## $Nutrient
## diff lwr upr p adj
## Ambient-Added -0.8205043 -1.23339 -0.4076185 0.0001319
## run full model for salvia biomass
m3 <- aov(log(Salvia.biomass)~ Microsite * Nutrient * arid.gradient, data=subset(census.arid, Salvia.biomass>0))
summary(m3) ## site and year + sitexmicrosite
## Df Sum Sq Mean Sq F value Pr(>F)
## Microsite 1 0.1 0.11 0.054 0.815771
## Nutrient 1 24.8 24.84 12.494 0.000465 ***
## arid.gradient 1 33.7 33.73 16.965 4.79e-05 ***
## Microsite:Nutrient 1 0.2 0.23 0.115 0.734281
## Microsite:arid.gradient 1 0.6 0.59 0.299 0.585029
## Nutrient:arid.gradient 1 20.3 20.28 10.199 0.001538 **
## Microsite:Nutrient:arid.gradient 1 0.0 0.00 0.000 0.988929
## Residuals 338 672.1 1.99
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(m3, "Microsite")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Nutrient, arid.gradient
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## Microsite, Nutrient, arid.gradient
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = log(Salvia.biomass) ~ Microsite * Nutrient * arid.gradient, data = subset(census.arid, Salvia.biomass > 0))
##
## $Microsite
## diff lwr upr p adj
## shrub-open 0.03535378 -0.26289 0.3335975 0.8157715
m3.n <- lm(log(Salvia.biomass)~ arid.gradient, data=subset(census.arid, Salvia.biomass>0 & Nutrient =="Added"))
m3.a <- lm(log(Salvia.biomass)~ arid.gradient, data=subset(census.arid, Salvia.biomass>0 & Nutrient =="Ambient"))
## abundance
## run full model for phacelia abundance
m1 <- glm.nb(Phacelia~ Microsite * Nutrient * arid.gradient, data=census.arid)
summary(m1) ## site and microsite
##
## Call:
## glm.nb(formula = Phacelia ~ Microsite * Nutrient * arid.gradient,
## data = census.arid, init.theta = 0.2308296117, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.03830 -0.81531 -0.76103 0.01823 3.03660
##
## Coefficients:
## Estimate Std. Error z value
## (Intercept) -0.0007756 0.5883363 -0.001
## Micrositeshrub 1.2705913 0.8115605 1.566
## NutrientAmbient 0.1077404 0.8333728 0.129
## arid.gradient 0.1858087 0.1944620 0.956
## Micrositeshrub:NutrientAmbient 0.1849576 1.1409892 0.162
## Micrositeshrub:arid.gradient 0.2621592 0.2696848 0.972
## NutrientAmbient:arid.gradient 0.0421013 0.2759568 0.153
## Micrositeshrub:NutrientAmbient:arid.gradient -0.0505405 0.3789622 -0.133
## Pr(>|z|)
## (Intercept) 0.999
## Micrositeshrub 0.117
## NutrientAmbient 0.897
## arid.gradient 0.339
## Micrositeshrub:NutrientAmbient 0.871
## Micrositeshrub:arid.gradient 0.331
## NutrientAmbient:arid.gradient 0.879
## Micrositeshrub:NutrientAmbient:arid.gradient 0.894
##
## (Dispersion parameter for Negative Binomial(0.2308) family taken to be 1)
##
## Null deviance: 585.87 on 839 degrees of freedom
## Residual deviance: 550.93 on 832 degrees of freedom
## AIC: 1941.5
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 0.2308
## Std. Err.: 0.0231
##
## 2 x log-likelihood: -1923.4540
anova(m1, test="Chisq")
## Warning in anova.negbin(m1, test = "Chisq"): tests made without re-
## estimating 'theta'
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.2308), link: log
##
## Response: Phacelia
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev
## NULL 839 585.87
## Microsite 1 19.9145 838 565.96
## Nutrient 1 1.0729 837 564.89
## arid.gradient 1 11.4485 836 553.44
## Microsite:Nutrient 1 1.0254 835 552.41
## Microsite:arid.gradient 1 1.4563 834 550.96
## Nutrient:arid.gradient 1 0.0064 833 550.95
## Microsite:Nutrient:arid.gradient 1 0.0167 832 550.93
## Pr(>Chi)
## NULL
## Microsite 8.098e-06 ***
## Nutrient 0.3002852
## arid.gradient 0.0007155 ***
## Microsite:Nutrient 0.3112354
## Microsite:arid.gradient 0.2275227
## Nutrient:arid.gradient 0.9362121
## Microsite:Nutrient:arid.gradient 0.8971935
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lsmeans(m1, pairwise~"Microsite")
## NOTE: Results may be misleading due to involvement in interactions
## $lsmeans
## Microsite lsmean SE df asymp.LCL asymp.UCL
## open -0.5548206 0.1205597 NA -0.7911133 -0.3185280
## shrub 0.1120837 0.1124787 NA -0.1083705 0.3325379
##
## Results are averaged over the levels of: Nutrient
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## open - shrub -0.6669043 0.1648821 NA -4.045 0.0001
##
## Results are averaged over the levels of: Nutrient
## Results are given on the log (not the response) scale.
## run full model for plantago biomass
m2 <- glm.nb(Plantago~ Microsite * Nutrient * arid.gradient, data=census.arid)
summary(m2) ## site and microsite
##
## Call:
## glm.nb(formula = Plantago ~ Microsite * Nutrient * arid.gradient,
## data = census.arid, init.theta = 0.1287536289, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.8053 -0.7211 -0.6578 -0.5689 2.4129
##
## Coefficients:
## Estimate Std. Error z value
## (Intercept) 1.0031515 0.7094622 1.414
## Micrositeshrub -2.8208986 1.0387678 -2.716
## NutrientAmbient -0.0810403 1.0160835 -0.080
## arid.gradient 0.3420451 0.2337751 1.463
## Micrositeshrub:NutrientAmbient 0.5580731 1.4672180 0.380
## Micrositeshrub:arid.gradient -0.7058890 0.3368271 -2.096
## NutrientAmbient:arid.gradient 0.0826214 0.3361349 0.246
## Micrositeshrub:NutrientAmbient:arid.gradient -0.0006522 0.4776644 -0.001
## Pr(>|z|)
## (Intercept) 0.15737
## Micrositeshrub 0.00662 **
## NutrientAmbient 0.93643
## arid.gradient 0.14343
## Micrositeshrub:NutrientAmbient 0.70368
## Micrositeshrub:arid.gradient 0.03611 *
## NutrientAmbient:arid.gradient 0.80584
## Micrositeshrub:NutrientAmbient:arid.gradient 0.99891
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(0.1288) family taken to be 1)
##
## Null deviance: 427.38 on 839 degrees of freedom
## Residual deviance: 414.78 on 832 degrees of freedom
## AIC: 1596.1
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 0.1288
## Std. Err.: 0.0138
##
## 2 x log-likelihood: -1578.1100
anova(m2, test="Chisq")
## Warning in anova.negbin(m2, test = "Chisq"): tests made without re-
## estimating 'theta'
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.1288), link: log
##
## Response: Plantago
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 427.38
## Microsite 1 5.5584 838 421.82 0.01839
## Nutrient 1 0.0296 837 421.79 0.86334
## arid.gradient 1 0.5610 836 421.23 0.45386
## Microsite:Nutrient 1 1.6621 835 419.56 0.19732
## Microsite:arid.gradient 1 4.7218 834 414.84 0.02978
## Nutrient:arid.gradient 1 0.0649 833 414.78 0.79889
## Microsite:Nutrient:arid.gradient 1 0.0000 832 414.78 0.99859
##
## NULL
## Microsite *
## Nutrient
## arid.gradient
## Microsite:Nutrient
## Microsite:arid.gradient *
## Nutrient:arid.gradient
## Microsite:Nutrient:arid.gradient
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lsmeans(m2, pairwise~"Microsite")
## NOTE: Results may be misleading due to involvement in interactions
## $lsmeans
## Microsite lsmean SE df asymp.LCL asymp.UCL
## open -0.1639688 0.1466943 NA -0.4514843 0.1235467
## shrub -0.6304166 0.1522519 NA -0.9288248 -0.3320084
##
## Results are averaged over the levels of: Nutrient
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## open - shrub 0.4664478 0.2114234 NA 2.206 0.0274
##
## Results are averaged over the levels of: Nutrient
## Results are given on the log (not the response) scale.
## run full model for salvia biomass
m3 <- glm.nb(Salvia~ Microsite * Nutrient * arid.gradient, data=census.arid)
summary(m3) ## site and microsite
##
## Call:
## glm.nb(formula = Salvia ~ Microsite * Nutrient * arid.gradient,
## data = census.arid, init.theta = 0.3061627656, link = log)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.3585 -1.1226 -0.8020 0.2021 2.2024
##
## Coefficients:
## Estimate Std. Error z value
## (Intercept) 2.39712 0.46918 5.109
## Micrositeshrub -0.02997 0.67161 -0.045
## NutrientAmbient 0.61208 0.67236 0.910
## arid.gradient 0.57763 0.15655 3.690
## Micrositeshrub:NutrientAmbient 0.16062 0.94881 0.169
## Micrositeshrub:arid.gradient 0.07096 0.22516 0.315
## NutrientAmbient:arid.gradient 0.24763 0.22629 1.094
## Micrositeshrub:NutrientAmbient:arid.gradient -0.14470 0.31899 -0.454
## Pr(>|z|)
## (Intercept) 3.24e-07 ***
## Micrositeshrub 0.964406
## NutrientAmbient 0.362646
## arid.gradient 0.000225 ***
## Micrositeshrub:NutrientAmbient 0.865571
## Micrositeshrub:arid.gradient 0.752644
## NutrientAmbient:arid.gradient 0.273802
## Micrositeshrub:NutrientAmbient:arid.gradient 0.650108
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Negative Binomial(0.3062) family taken to be 1)
##
## Null deviance: 785.98 on 839 degrees of freedom
## Residual deviance: 721.96 on 832 degrees of freedom
## AIC: 2994
##
## Number of Fisher Scoring iterations: 1
##
##
## Theta: 0.3062
## Std. Err.: 0.0230
##
## 2 x log-likelihood: -2976.0340
anova(m3, test="Chisq")
## Warning in anova.negbin(m3, test = "Chisq"): tests made without re-
## estimating 'theta'
## Analysis of Deviance Table
##
## Model: Negative Binomial(0.3062), link: log
##
## Response: Salvia
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev Pr(>Chi)
## NULL 839 785.98
## Microsite 1 0.258 838 785.72 0.61139
## Nutrient 1 3.609 837 782.11 0.05747
## arid.gradient 1 54.596 836 727.51 1.48e-13
## Microsite:Nutrient 1 4.529 835 722.98 0.03332
## Microsite:arid.gradient 1 0.005 834 722.98 0.94599
## Nutrient:arid.gradient 1 0.870 833 722.11 0.35089
## Microsite:Nutrient:arid.gradient 1 0.145 832 721.96 0.70327
##
## NULL
## Microsite
## Nutrient .
## arid.gradient ***
## Microsite:Nutrient *
## Microsite:arid.gradient
## Nutrient:arid.gradient
## Microsite:Nutrient:arid.gradient
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lsmeans(m3, pairwise~Microsite*Nutrient)
## NOTE: Results may be misleading due to involvement in interactions
## $lsmeans
## Microsite Nutrient lsmean SE df asymp.LCL asymp.UCL
## open Added 0.6995864 0.1351555 NA 0.4346865 0.9644863
## shrub Added 0.4610742 0.1382722 NA 0.1900656 0.7320828
## open Ambient 0.5839160 0.1380287 NA 0.3133848 0.8544472
## shrub Ambient 0.9312613 0.1338667 NA 0.6688874 1.1936351
##
## Results are given on the log (not the response) scale.
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df z.ratio p.value
## open,Added - shrub,Added 0.2385122 0.1933552 NA 1.234 0.6054
## open,Added - open,Ambient 0.1156704 0.1931811 NA 0.599 0.9325
## open,Added - shrub,Ambient -0.2316749 0.1902296 NA -1.218 0.6154
## shrub,Added - open,Ambient -0.1228418 0.1953743 NA -0.629 0.9228
## shrub,Added - shrub,Ambient -0.4701871 0.1924565 NA -2.443 0.0692
## open,Ambient - shrub,Ambient -0.3473453 0.1922816 NA -1.806 0.2702
##
## Results are given on the log (not the response) scale.
## P value adjustment: tukey method for comparing a family of 4 estimates
## treatment plots
census.long <- gather(census.arid, species, biomass, 12:14)
census.long[,"species"] <- as.factor(census.long$species)
## microsite average
census.micro <- census.long %>% filter(biomass>0) %>% group_by(Microsite, species) %>% summarize(Biomass=mean(biomass), error=se(biomass))
ggplot(census.micro, aes(x=species, y=Biomass, fill=Microsite)) + geom_bar(position=position_dodge(), stat="identity", colour="black") + scale_fill_brewer()+ geom_errorbar(aes(ymin=Biomass-error, ymax=Biomass+error),
width=.2, # Width of the error bars
position=position_dodge(.9))+ theme_Publication()
## Warning: `legend.margin` must be specified using `margin()`. For the old
## behavior use legend.spacing
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## nutrient average
census.nut <- census.long %>% filter(biomass>0) %>% group_by(Nutrient, species) %>% summarize(Biomass=mean(biomass), error=se(biomass))
ggplot(census.nut, aes(x=species, y=Biomass, fill=Nutrient)) + geom_bar(position=position_dodge(), stat="identity",colour="black") + scale_fill_brewer()+ geom_errorbar(aes(ymin=Biomass-error, ymax=Biomass+error),
width=.2, # Width of the error bars
position=position_dodge(.9))+ theme_Publication()
## Warning: `legend.margin` must be specified using `margin()`. For the old
## behavior use legend.spacing
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## aridity average
ggplot(census.long, aes(x=arid.gradient, y=biomass, fill=species, colour=species)) + theme_Publication()+ stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=biomass), color="#009E73", fill="#009E7340", data=subset(census.long, species=="Phacelia.biomass" & biomass>0)) + stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=biomass), color="#E69F00",fill="#E69F0040", data=subset(census.long, species=="Plantago.biomass" & biomass>0))+ stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=biomass), color="#56B4E9", fill="#56B4E940", data=subset(census.long, species=="Salvia.biomass" & biomass>0))
## Warning: `legend.margin` must be specified using `margin()`. For the old
## behavior use legend.spacing
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
m1 <- lm(log(biomass)~arid.gradient, data=subset(census.long, species=="Phacelia.biomass" & biomass >0))
m2 <- lm(log(biomass)~arid.gradient, data=subset(census.long, species=="Plantago.biomass" & biomass>0))
m3 <- lm(log(biomass)~arid.gradient, data=subset(census.long, species=="Salvia.biomass" & biomass>0))
## Regressions To Separate Phylogenetic Attraction And Repulsion
## sppregs(community[,13:53], )
### Network analysis
library(igraph)
library(statnet)
## reload native vs non-native species
status <- read.csv("Data//ERG.specieslist.csv")
shrub.comm <- subset(community, Microsite=="shrub", select=13:53)
shrub.comm <- shrub.comm[,colSums(shrub.comm)!=0]
open.comm <- subset(community, Microsite=="open", select=13:53)
open.comm <- open.comm[,colSums(open.comm)!=0]
## Shrub
## correlation species network
network <- data.frame(cor(shrub.comm))
network[,"To"] <- colnames(network)
test <- gather(network, From, correlation, 1:(ncol(network)-1))
test <- subset(test, correlation>0.10 & correlation != 1 | correlation < -0.10 )
n.shrub <- graph_from_data_frame(test[,1:2], directed=TRUE)
## plot network circle
lo <- layout_in_circle(n.shrub)
plot(n.shrub, layout=lo)
transitivity(n.shrub, type = "local")
## [1] 0.16666667 0.06060606 0.13333333 0.08888889 0.00000000 0.03296703
## [7] 0.07575758 0.10714286 0.03684211 0.06535948 0.00000000 0.07142857
## [13] 0.07142857 0.07142857 0.02222222 0.00000000 0.00000000 0.16666667
## [19] 0.00000000 0.00000000 0.10714286 0.16666667 0.00000000 0.13333333
## [25] 0.06666667 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [31] 0.00000000
transitivity(n.shrub, type = "global")
## [1] 0.2755102
## colour graphs
shapes <- V(n.shrub)$name %in% (subset(status, status=="non.native", select=1))[,1] +1
plot(n.shrub, layout=layout_on_grid(n.shrub),vertex.shape=c("circle", "square")[shapes], vertex.color=c("tomato2", "royalblue")[shapes])
## open
## correlation species network
network <- data.frame(cor(open.comm))
network[,"To"] <- colnames(network)
test <- gather(network, From, correlation, 1:(ncol(network)-1))
test <- subset(test, correlation>0.10 & correlation != 1 | correlation < -0.10 )
n.open <- graph_from_data_frame(test[,1:2], directed=TRUE)
## plot network circle
lo <- layout_in_circle(n.open)
plot(n.open, layout=lo)
## colour graphs
shapes <- V(n.open)$name %in% (subset(status, status=="non.native", select=1))[,1] +1
plot(n.open, layout=layout_on_grid(n.open),vertex.shape=c("circle", "square")[shapes], vertex.color=c("tomato2", "royalblue")[shapes])
## statistics
transitivity(n.open, type = "local")
## [1] 0.09890110 0.17857143 0.03333333 0.06666667 0.16666667 0.03921569
## [7] 0.03030303 0.20000000 0.20000000 0.07189542 0.00000000 0.00000000
## [13] 0.00000000 0.00000000 0.06666667 0.03571429 0.06666667 0.06666667
## [19] 0.06666667 0.00000000 0.16666667 0.00000000 0.16666667 0.16666667
## [25] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.16666667
## [31] 0.00000000 0.00000000 0.00000000
transitivity(n.open, type = "global")
## [1] 0.2934783
### indicator species analysis
library(indicspecies)
## indicator species analysis
indval <- multipatt(community[,13:53], community$Microsite, control=how(nperm=999))
summary(indval)
##
## Multilevel pattern analysis
## ---------------------------
##
## Association function: IndVal.g
## Significance level (alpha): 0.05
##
## Total number of species: 41
## Selected number of species: 14
## Number of species associated to 1 group: 14
##
## List of species associated to each combination:
##
## Group open #sps. 8
## stat p.value
## E.cicutarium 0.558 0.001 ***
## L.gracilis 0.427 0.001 ***
## A.wrangelianus 0.201 0.001 ***
## C.brevipes 0.171 0.046 *
## A.lentiginosus 0.149 0.032 *
## C.rigida 0.149 0.014 *
## A.grandiflora 0.129 0.014 *
## Boraginaceae.sp. 0.120 0.031 *
##
## Group shrub #sps. 6
## stat p.value
## C.fremontii 0.379 0.001 ***
## M.glabrata 0.277 0.001 ***
## P.tanacetifolia 0.267 0.001 ***
## A.tessellata 0.199 0.005 **
## B.nigra 0.179 0.013 *
## E.nitidum 0.172 0.005 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## species accumilation curves
accum1 <- specaccum(subset(community, Microsite=="shrub", select=13:53), method="random", permutations=1000)
accum2 <- specaccum(subset(community, Microsite=="open", select=13:53), method="random", permutations=1000)
plot(accum2, ci.col="Grey20", xlab="Sampling effort", cex.axis=1.5, cex.lab=1.8, ylab="Species richness")
plot(accum1,add=T , col="Grey50", ci.col="Grey60")
library("cluster")
library("factoextra")
library("magrittr")
comm.sum <- community %>% group_by(Microsite, Site) %>% summarize_if(is.numeric, funs(sum))
comm.sum <- data.frame(comm.sum)
rownames(comm.sum) <- paste(comm.sum$Microsite,comm.sum$Site)
## coreelation matrix
### Distance measures
res.dist <- get_dist(comm.sum[,13:53], stand = TRUE, method = "euclidean")
fviz_dist(res.dist, gradient = list(low = "#00AFBB", mid = "white", high = "#FC4E07"))
## dendrogram
## transform data
comm.trans <- decostand(comm.sum[,13:53], "hell")
## clean data for ordination
## see distribution of spp
boxplot(comm.trans, xaxt="n")
labs <- colnames(comm.trans)
text(cex=0.8, x=1:41-1, y=-0.12, labs, xpd=TRUE, srt=45)
## remove spp with only one instancve
comm.trans <- comm.trans[,!colSums(comm.trans)==apply(comm.trans, 2, max)]
## replace outliers with mean
avg.max <- function(x) {
y = max(x)
avg = mean(x)
x[x==y] <- avg
return(x)
}
## dot chart to find outliers (remove or Avg)
#dotchart(comm.trans$E.cicutarium) ## Erodium
comm.trans[,"E.cicutarium"] <- avg.max(comm.trans$E.cicutarium) ## removed outlier
#dotchart(comm.trans$A.wrangelianus) ## Chilean trefoil
comm.trans[,"A.wrangelianus"] <- NULL ## removed entire species
#dotchart(comm.trans$A.lentiginosus) ##
comm.trans[,"A.lentiginosus"] <- avg.max(comm.trans$A.lentiginosus) ## removed outlier
#dotchart(comm.trans$H.vulgare) ## Hordeum
comm.trans[,"H.vulgare"] <- NULL ## removed entire species
#dotchart(comm.trans$Pectocarya.spp) ##
comm.trans[,"Pectocarya.spp"] <- avg.max(comm.trans$Pectocarya.spp) ## removed outlier
#dotchart(comm.trans$L.arizonicus) ## Lupin
comm.trans[,"L.arizonicus"] <- NULL ## removed entire species
#dotchart(comm.trans$M.bellioides) ##
comm.trans[,"M.bellioides"] <- NULL ## removed entire species
#dotchart(comm.trans$B.nigra) ## Mustard
comm.trans[,"B.nigra"] <- NULL ## removed entire species
#dotchart(comm.trans$N.demissum) ## Sand Matt
comm.trans[,"N.demissum"] <- avg.max(comm.trans$N.demissum) ## removed outlier
#dotchart(comm.trans$L.gracilis) ##
comm.trans[,"L.gracilis"] <- avg.max(comm.trans$L.gracilis) ## removed outlier
#dotchart(comm.trans$A.grandiflora) ## Amsinckia
comm.trans[,"A.grandiflora"] <- NULL ## removed entire species
#dotchart(comm.trans$B.diandrus) ## Bromus diandrus
comm.trans[,"B.diandrus"] <- NULL ## removed entire species
#dotchart(comm.trans$M.affinis) ##
comm.trans[,"M.affinis"] <- NULL ## removed entire species
#dotchart(comm.trans$P.crenulata) ##
comm.trans[,"P.crenulata"] <- NULL ## removed entire species
#dotchart(comm.trans$Erinoginum.spp) # buckwheat
comm.trans[,"Erinoginum.spp"] <- avg.max(comm.trans$Erinoginum.spp) ## removed outlier
#dotchart(comm.trans$C.lasiophyllus) #
comm.trans[,"C.lasiophyllus"] <- NULL ## removed entire species
library(usdm)
library(corrplot)
## Check for collinearity
vifcor(comm.trans)
## 4 variables from the 25 input variables have collinearity problem:
##
## E.wallacei P.insularis E.glyptosperma L.decorus
##
## After excluding the collinear variables, the linear correlation coefficients ranges between:
## min correlation ( L.gracilis ~ S.barbatus ): -0.003266766
## max correlation ( C.fremontii ~ M.glabrata ): 0.8450794
##
## ---------- VIFs of the remained variables --------
## Variables VIF
## 1 B.rubens Inf
## 2 E.cicutarium Inf
## 3 S.barbatus Inf
## 4 C.barbigera Inf
## 5 C.claviformis Inf
## 6 A.lentiginosus Inf
## 7 C.rigida Inf
## 8 P.tanacetifolia Inf
## 9 Pectocarya.spp Inf
## 10 D.capitatum Inf
## 11 C.brevipes Inf
## 12 M.glabrata Inf
## 13 C.fremontii Inf
## 14 C.intermedia Inf
## 15 N.demissum Inf
## 16 L.gracilis Inf
## 17 A.tessellata Inf
## 18 P.secunda Inf
## 19 L.sparsiflorus Inf
## 20 Erinoginum.spp Inf
## 21 E.nitidum Inf
## drop Claviformis because of collinear problems in P.insularis
comm.trans[,"C.claviformis"] <- NULL ## removed entire species
comm.trans[,"L.decorus"] <- NULL ## removed entire species
comm.trans[,"E.glyptosperma"] <- NULL ## removed entire species
comm.trans[,"E.wallacei"] <- NULL ## removed entire species
cor.dat <- cor(comm.trans[,1:20])
corrplot(cor.dat, method="number")
## calculate distances
dis <- vegdist(comm.trans, method="bray")
## cluster analysis
clus <- hclust(dis, "ward.D2")
## cluster colours
colz <- c("#3e4444", "#86af49", "#405d27","#c1946a")
fviz_dend(clus, k = 4, # Cut in four groups
cex = 0.5, # label size
k_colors = colz,
color_labels_by_k = TRUE, # color labels by groups
rect = TRUE # Add rectangle around groups
)
grp <- cutree(clus, 4)
## Interpretation of classes
## get soil moisture from site/microsite
smc.avg <- smc.end %>% group_by(Site, Microsite) %>% summarize(mean.smc=mean(swc.avg, na.rm=T))
smc.avg <- data.frame(smc.avg)
smc.avg[,"grp"] <- as.factor(c(3,3,2,1,4,4,1,1,4,4,3,3,2,2))
boxplot(mean.smc ~ grp, data=smc.avg)
## CA or PCA
dca1 <- decorana(comm.trans) ## length of gradient >2 & determine relative differences in community composition
## conduct ordination
ord <- cca(comm.trans)
## calculate priority
spp.priority <- colSums(comm.trans)
## plot ordination
par(mar=c(4.5,4.5,0.5,0.5))
plot(ord, type="n")
ordiellipse(ord, grp, lty = 2, col = "grey80", draw="polygon", alpha=150)
orditorp(ord, display = "species", cex = 0.7, col = "darkorange3", priority=spp.priority, air=0.5)
orditorp(ord, display = "sites", cex = 0.7, col = "darkslateblue", air=0.1)
##collect environmental variables for site
nutrients <- read.csv("Data/ERG.soilnutrients.csv")
nutrients.mean <- nutrients %>% group_by(microsite, Site) %>% summarise_all(funs(mean))
nutrients.vars <- data.frame(nutrients.mean)
## summarize daily means across sites
means <- HOBO.data %>% group_by(Microsite, Site) %>% summarize(Temp.=mean(Temp, na.rm=T),rh=mean(RH, na.rm=T),temp.se=se(Temp),rh.se=se(RH))
means <- data.frame(means)
## soil moisture
smc.avg <- smc.early %>% group_by(Microsite, Site) %>% summarize(SMC=mean(swc.avg, na.rm=T))
envs <- data.frame(swc=smc.avg[,"SMC"],nutrients.vars[,c("N","P","K")], means[,c("Temp.","rh")])
## Check for collinearity
cor(envs)
## SMC N P K Temp. rh
## SMC 1.0000000 -0.31692385 0.44854712 0.81694831 -0.6306962 0.9176776
## N -0.3169238 1.00000000 0.05879919 -0.05275422 0.4188434 -0.4374109
## P 0.4485471 0.05879919 1.00000000 0.64885814 -0.5264257 0.5353719
## K 0.8169483 -0.05275422 0.64885814 1.00000000 -0.5705341 0.7740852
## Temp. -0.6306962 0.41884336 -0.52642569 -0.57053407 1.0000000 -0.8625519
## rh 0.9176776 -0.43741089 0.53537193 0.77408521 -0.8625519 1.0000000
envs[,"K"] <- NULL ## drop potassium for being correlated
envs[,"rh"] <- NULL ## drop humidity for being correlated
ord.env <- envfit(ord, envs)
plot(ord.env)
# ordicluster(ord, clus, col="blue")
# ## conduct ordination with gradient analysis
# ord <- cca(comm.trans~SMC+N+P+Temp.,data=envs)
# (R2adj <- RsquareAdj(ord)$adj.r.squared) ## 30.0% of variation explained
#
# ord <- cca(comm.trans~.,data=envs)
# ord.0 <- cca(comm.trans~1,data=envs)
# m <- ordistep(ord.0, scope=formula(ord))
#
#
# ## plot ordination
# par(mar=c(4.5,4.5,0.5,0.5))
# plot(ord, type="n") # display="bp", ylim=c(-2,2),xlim=c(-2,2))
# ordiellipse(ord, grp, lty = 2, col = colz, draw="polygon", alpha=150)
# orditorp(ord, display = "species", cex = 0.7, col = "darkred", priority=spp.priority, air=0.5)
# orditorp(ord, display = "sites", cex = 0.7, col = "black", air=0.1)
Repeated of analyses separating long- and short- term effets
community.arid <- merge(community, site.climate, by=c("Year","Site"))
library(lmerTest)
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
##
## expand
## Loading required package: lme4
##
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
##
## lmList
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:lsmeans':
##
## lsmeans
## The following object is masked from 'package:stats':
##
## step
m1 <- glmer(Abundance~Microsite * arid.gradient + (1|Year), family="poisson", data=community.arid)
mean.year <- community.arid %>% group_by(Microsite, arid.gradient, Year) %>% summarize(abd=mean(Abundance),rich=mean(Richness), bio=mean(Biomass))
m1 <- lmer(ihs(bio)~Microsite * arid.gradient + (1|Year), data=mean.year)
shapiro.test(resid(m1))
##
## Shapiro-Wilk normality test
##
## data: resid(m1)
## W = 0.96861, p-value = 0.5438
anova(m1)
## Analysis of Variance Table of type III with Satterthwaite
## approximation for degrees of freedom
## Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
## Microsite 1.6110 1.6110 1 23.000 5.877 0.02361 *
## arid.gradient 15.2136 15.2136 1 23.821 55.497 1.141e-07 ***
## Microsite:arid.gradient 0.7531 0.7531 1 23.000 2.747 0.11101
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
m2 <- lmer(ihs(abd)~Microsite * arid.gradient + (1|Year), data=mean.year)
shapiro.test(resid(m2))
##
## Shapiro-Wilk normality test
##
## data: resid(m2)
## W = 0.98276, p-value = 0.9104
anova(m2)
## Analysis of Variance Table of type III with Satterthwaite
## approximation for degrees of freedom
## Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
## Microsite 0.074 0.074 1 23.000 0.191 0.6662
## arid.gradient 60.944 60.944 1 23.943 156.661 5.378e-12 ***
## Microsite:arid.gradient 0.028 0.028 1 23.000 0.073 0.7898
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
m3 <- lmer(ihs(rich)~Microsite * arid.gradient + (1|Year), data=mean.year)
shapiro.test(resid(m3))
##
## Shapiro-Wilk normality test
##
## data: resid(m3)
## W = 0.99072, p-value = 0.9956
anova(m3)
## Analysis of Variance Table of type III with Satterthwaite
## approximation for degrees of freedom
## Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
## Microsite 0.30839 0.30839 1 24 1.4920 0.2337731
## arid.gradient 2.93275 2.93275 1 24 14.1883 0.0009479 ***
## Microsite:arid.gradient 0.23778 0.23778 1 24 1.1504 0.2941405
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ggplot(mean.year, aes(x=arid.gradient, y=bio, fill=Microsite, colour=Microsite)) + theme_Publication()+ geom_point()
## Warning: `legend.margin` must be specified using `margin()`. For the old
## behavior use legend.spacing
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : font family not found in Windows font database
#
# stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=biomass), color="#009E73", fill="#009E7340", data=subset(census.long, species=="Phacelia.biomass" & biomass>0)) + stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=biomass), color="#E69F00",fill="#E69F0040", data=subset(census.long, species=="Plantago.biomass" & biomass>0))+ stat_smooth(method="lm", formula= y~exp(x),aes(x=arid.gradient, y=biomass), color="#56B4E9", fill="#56B4E940", data=subset(census.long, species=="Salvia.biomass" & biomass>0))